How to write this sql code ?

for example below shows:
create table temp
order_type varchar2(30),
order_num number);
insert into temp values('apple',000001);
insert into temp values('banana',000002);
insert into temp values('chair',000003);
select *
from temp
where instr(order_type,decode(x,1,'a',2,'b',2,'c',order_type)) >0
if i let x equals 2 and i want to get b and c from above querying .
why above query could not get 'c' and only get 'b' if i give 2 to x ?
how to write above select clause ?
who can help me ?
thanks!

Decode will return the first match;
SQL> select decode(2,1,'a',2,'b',2,'c')
from dual
D
b
1 row selected.This may help;
old: select *
from temp
where regexp_like(order_type, case to_number(&x)
                                 when 1 then 'a'
                                 when 2 then 'b|c'
                              end)
new: select *
from temp
where regexp_like(order_type, case to_number(2)
                                 when 1 then 'a'
                                 when 2 then 'b|c'
                              end)
ORDER_TYPE                      ORDER_NUM
banana                                  2
chair                                   3
2 rows selected.

Similar Messages

  • How to write this sql query in php code ?

    for example:
    insert into temp
    select *
    from testtable;
    after this, i will query data from sql below:
    select *
    from temp;
    how to write this php code ?
    who can help me ?
    thanks!

    Have a look at the manual to find out how to issue queries.
    http://us3.php.net/oci8

  • How to write this SQL query

    We have a table, the structure as below: (I put a blank row in the middle to make it clear)
    Product_ID     Retailer     Retail_Price
    1001          A          1.2
    1001          B          1.5
    1001          C          1.4
    1002          B          2.0
    1002          C          2.1
    1002          E          1.8
    1002          F          2.0
    1003          A          1.7
    1003          C          1.5
    Basically we use the table to compare the retail price for different retailers in terms of different products. My customer asked me to give a report based on above table but only shows the retail prices which contain retailer A.
    For example, on above table I need to give a report like below:
    Product_ID     Retailer     Retail_Price
    1001          A          1.2
    1001          B          1.5
    1001          C          1.4
    1003          A          1.7
    1003          C          1.5
    Can anybody give some ideas on how I should write a SQL to achieve this.
    Many thanks!

    SQL> create table product(
    2 Product_ID varchar2(10),
    3 Retailer varchar2(10),
    4 Retail_Price number(7,2)
    5 )
    6 /
    Table created.
    SQL> insert into product values('1001','A',1.2)
    2 /
    1 row created.
    SQL> insert into product values('1001','B',1.5)
    2 /
    1 row created.
    SQL> insert into product values('1001','C',1.4)
    2 /
    1 row created.
    SQL> insert into product values('1002','B',2.0)
    2 /
    1 row created.
    SQL> insert into product values('1002','C',2.1)
    2 /
    1 row created.
    SQL> insert into product values('1002','E',1.8)
    2 /
    1 row created.
    SQL> insert into product values('1002','F',2.0)
    2 /
    1 row created.
    SQL> insert into product values('1003','A',1.7)
    2 /
    1 row created.
    SQL> insert into product values('1003','C',1.5)
    2 /
    1 row created.
    SQL> select * from product
    2 /
    PRODUCT_ID RETAILER RETAIL_PRICE
    1001 A 1.2
    1001 B 1.5
    1001 C 1.4
    1002 B 2
    1002 C 2.1
    1002 E 1.8
    1002 F 2
    1003 A 1.7
    1003 C 1.5
    9 rows selected.
    SQL> select * from product where PRODUCT_ID in (
    2 select distinct PRODUCT_ID from product where RETAILER='A')
    3 /
    PRODUCT_ID RETAILER RETAIL_PRICE
    1001 A 1.2
    1001 B 1.5
    1001 C 1.4
    1003 A 1.7
    1003 C 1.5

  • How to write this java code in jsp using jstl  tags?

    Can anybody help me on this?
    I dont know how to check the containsKey using jstl tags?
    <%
         LinkedHashMap yearMap     =     (LinkedHashMap)request.getAttribute("yearMap");
         TreeSet nocSet               =     (TreeSet)request.getAttribute("nocSet");
         Iterator     yearMapIt     =     yearMap.keySet().iterator();
         while(yearMapIt.hasNext())
              int yearValue               =     (Integer)yearMapIt.next();
    %>
    <tr>
              <td><%=yearValue%></td>
    <%
              LinkedHashMap monthMap     =     (LinkedHashMap)yearMap.get(yearValue);
              Iterator     nocSetIt     =     nocSet.iterator();
              while(nocSetIt.hasNext())
                   String nCase=(String)nocSetIt.next();
                   if(monthMap.containsKey(nCase))
                        String count     =     (String)monthMap.get(nCase);
    %>
                        <td> <%= count %> </td>
    <%            }
                   else
    %>          
                        <td> 0 </td>     
    <%          
    %>
    </tr>
    <% } %>Edited by: avn_venki on Feb 18, 2008 11:54 PM

    <c:forEach var="yearMap" items="${requestScope.yearMap}">
         <th> <c:out value="${yearMap.key}"/> </th>
    <bean:define id="monthMap" value="${yearMap.value}"/>
    <c:forEach var="nocSet" items="${nocSet}">
    then how to write containsKey using tags??

  • How to write this sql  query to oracle

    Hi sir,
    i am using one query in my sql stored procedure that is:
    select @maxtime=CONVERT(Time,Out_Time+DATEADD(n,60,0)) from shift where Shift_Code = @ShiftCode
    so here i am getting this value 01/01/1900 12:00 AM
    the same i used in oracle my query is :
    to_char(Out_Time,'1900-01-01' + 0/(24*60),'DD/MM/YYYY HH:MI AM')
    INTO v_maxtime
    FROM shift
    WHERE Shift_Code = v_ShiftCode;
    but getting error that is: Encountered the symbol INTO when expecting one of the following :=(%;
    am i doing any thing wrong.
    thanks

    APC wrote:
    The error you're getting is a syntax error. In this case because you've mangled the TO_CHAR syntax. Alas I cannot give you the correct version because I cannot unpick what you're trying to do with that statement.
    It would be easier if you expalined what business logic you're trying to implement instead of asking us to interpret a piece of shonky SQL.It's yet another of the OP's questions about how to do DATEs in Oracle (so many threads it can get very confusing - even though the OP has been asked to stick to one thread!).
    The code looks like it's based on the answer I gave here:
    How to get exact query of sql in oracle?
    but clearly he doesn't understand the basic syntax of Oracle or the datatypes he's using. Sometimes you just have to give up... (I know I have)

  • How to write the SQL codes  of the login system for a database system

    If I have a table stored with a Column staff_ID and Password. How can I make use of this 2 columns information to setup the login system?

    Hi,
    Create Table Modules          -----e.g. payroll, inventory etc.
    (ModID    NUMBER(10),
    ModName  VARCHAR2(50)); 
    Create Table Modules_Forms    ------e.g. Sales Transaction Form
    (FormID   NUMBER(10),
    ModID    NUMBER(10),
    FmxName  VARCHAR2(32));           
    Create Table Modules_Reports  ------e.g. Sales Report
    (RepID    NUMBER(10),
    ModID    NUMBER(10),
    RepName  VARCHAR2(32));           
    Create Table Usr              ------------From the Employee Information Module
    (UserID   VARCHAR2(20),       ------------you can find the designation of
    Password VARCHAR2(10)        ------------the user who wants to connect
    Emp_Code Varchar2(25));      ------------that is why, I am Addng Emp_Code.
    Create Table User_Modules     ------------Control the Module Access.
    (UserID   VARCHAR2(20);
    ModID    NUMBER(10),
    Access   VARCHAR2(1));
    Create Table User_Forms       ------------Control the Forms Access
    (UserID   VARCHAR2(20),
    FormID   NUMBER(10),
    Read     VARCHAR2(1),
    Write    VARCHAR2(1),
    Execute  VARCHAR2(1),
    Delete   VARCHAR2(1));
    Create Table User_Reports     ------------Control the Report Access
    (UserID   VARCHAR2(20),
    RepID    NUMBER(10),
    Access   VARCHAR2(1));
    1 ) After Creating these Tables, Control the Application Access of the users
        From the application (Oracle Forms).
    2 ) I think you should create a Menu from oracle forms.
    3 ) For Controlling the Database Level Access, you can create a ROLE
    4 ) Forms Forum Site:-
        http://www.forums.oracle.com/forums/forum.jsp?forum=82Regards
    Muhammad Waseem Haroon
    [email protected]

  • How do I write this SQL command in Oracle

    Hi all
    I wriote this SQ L statement in Ms SQL Server. How do I write this sql command in Oracle?
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    I am very interested in this part:
    SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007
    thanks
    Edited by: user631364 on Oct 27, 2008 8:25 AM
    Edited by: user631364 on Oct 27, 2008 8:26 AM
    Edited by: user631364 on Oct 27, 2008 8:27 AM

    Thank you!!
    Now let me aslk the second part of my question.
    This sql command:
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    was created with this query in SQL Server and then I saved it in a store procedure, that I scheduled to run montlhy
    SET ANSI_NULLS ON
    DECLARE @SQLString NVARCHAR(4000)
    /* Build the SQL string once.*/
    SET @SQLString = 'ALTER VIEW dbo.Consumption AS SELECT TOP 100 PERCENT ID, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 12) +
    "'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 12) +
    … (GOES FROM current month -12 to current month -1)
    , CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 1) +"'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 1) +
    ' FROM dbo.MasterConsumption WHERE YEAR_MONTH >= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-12 ) +"'" +
    ' AND YEAR_MONTH <= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-1 ) +"'" +
    ' GROUP BY ID ORDER BY ID '
    EXEC sp_executesql @SQLString
    Is that something that can be done in Oracle in the same way?
    Do you use another approach?
    please advice
    Edited by: user631364 on Oct 27, 2008 10:19 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:22 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:24 AM

  • How can i write this C-Code in G-Code

    hallo
    how can I write this C-Code in LabVIew ,
    for a=0; a=<10; a++
       for b=0; b=5 ; b+2
            X= 3+b;
      Y=1+a;
    please see the attachment and tell me where is the problem
    Attachments:
    Unbenannt 11.vi ‏43 KB

    Well, at least you tried and got some of it right.
    I think this should do what you want, but my C is rusty. Is the increment performed before or after the loop executes? If it's after, then I believe the loop should iterate 11 times, not 10.
    In any case, you should note that for a literal translation, you would need to add a sequence structure to guarantee that Y was written to only after the inner loop finished because of the way data-flow works.. Also, note that controls and indicators in LabVIEW are not equivalent to variables. They can be used as such, but they usually should not be.
    Another point about this is that you probably want to use the correct data type - the orange terminals are floating point indicators (of double precision, in this case) and you want integers.
    To learn more about LabVIEW, I suggest you try looking at some of these tutorials.
    Try to take over the world!
    Attachments:
    C.png ‏4 KB

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • How to write a sql query to retrieve data entered in the past 2 weeks

    Hi,
    I have file names and last accessed date(java.sql.Date format) stored in my database table, I would like to know how I can write a query to get the name of files accessed in the past 2 weeks,I use open sql server at the back end.
    Thanks in advance.

    This has essentially nothing to do with JDBC. JDBC is just an API to execute the SQL language using Java and thus interact with the databases.
    Your problem is related to the SQL language, you don't know how to write the SQL language. I suggest you to go through a SQL tutorial (there is one at w3schools.com) and to read the SQL documentation which come along with the database in question. A decent database manfacturer has a website and probably also a discussion forum / mailinglist as well.
    I'll give you a hint: you can just use equality operators in SQL like everywhere. For example: "WHERE date < somedate".

  • How to write the dynamic code for RadioGroupByKey and Check Boxes?

    Hi,
    Experts,
    I have created a WD ABAP application in that i have used RadioGroupByKey and CheckBox Ui elements but i want how to write the dynamic code to that i want to display male and female to RadioGroupByKey and 10  lables to check boxs.
    Please pass me some idea on it and send any documents on it .
    Thanks in advance ,
    Shabeer ahmed.

    Refer this for check box:
    Do check :
    bind_checked property is bind to a node with cardinality of 1:1
    CHECK_BOX_NODE <---node name
    -CHECK_BOX_VALUE <--attribute name of type wdy_boolean
    put this code under your WDDOMODIFYVIEW:
    DATA:
    lr_container TYPE REF TO cl_wd_uielement_container,
    lr_checkbox TYPE REF TO cl_wd_checkbox.
    get a pointer to the RootUIElementContainer
    lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
    lr_checkbox = cl_wd_checkbox=>new_checkbox(
    text = 'WD_Processor'
    bind_checked = 'CHECK_BOX_NODE.CHECK_BOX_VALUE'
    view = view ).
    cl_wd_matrix_data=>new_matrix_data( element = lr_checkbox ).
    lr_container->add_child( lr_checkbox ).
    Refer this for Radiobutton :
    dynamic radio button in web dynpro abao
    Edited by: Saurav Mago on Jul 17, 2009 10:43 PM

  • How to write this query ?

    how to write this query ?
    list the emp name who is working for the highest avg sal department.
    I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?
    the row_number version is like this
    select emp.* from emp ,
    select deptno, row_number() over (order by avg(sal) desc) r from emp
    group by deptno
    )e
    where e.r = 1
    and emp.deptno = e.deptno

    Hi,
    806540 wrote:
    how to write this query ?
    list the emp name who is working for the highest avg sal department.
    I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?ROW_NUMBER is just plain SQL, and has been since Oracle 8.1.
    ROW_NUMBER (or its close relative, RANK) is the simplest and most efficient way to solve this problem. Why not do this the right way?
    the row_number version is like this
    select emp.* from emp ,
    select deptno, row_number() over (order by avg(sal) desc) r from emp
    group by deptno
    )e
    where e.r = 1
    and emp.deptno = e.deptno
    If there happens to be a tie (that is, two or more departments have the same average sal, and it is the highest), then the query above will only arbitrarily treat one of them (no telling which one) as the highest. Change ROW_NUMBER to RANK to get all departments with a claim to having the highest average sal.
    You could use the ROWNUM pseudo-column instead of ROW_NUMBER, if all you want to do is avoid ROW_NUMBER.
    Without using ROW_NUMBER or RANK, there are lots of ways involving other analytic functions, such as AVG and MAX.
    If you really, really don't want to use analytic functions at all, you can do this:
    SELECT     *
    FROM     scott.emp
    WHERE     deptno     IN  (
                      SELECT       deptno
                      FROM       scott.emp
                      GROUP BY  deptno
                      HAVING       AVG (sal) =  (
                                                       SELECT    MAX (AVG (sal))
                                               FROM          scott.emp
                                               GROUP BY  deptno
    ;

  • Who can help me write this Java code show the prime number ???? PLEASEEEEEE

    Write java code print prime number like this
    Sample Screen Print:
    Initial matrix with N = 37
    2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37
    Intermediate results (after 1st iteration)
    2 3 5 7 9
    11 13 15 17 19
    21 23 25 27 29
    31 33 35 37
    Intermediate results (after 2nd iteration)
    2 3 5 7
    11 13 17 19
    23 25 29
    31 35 37
    Intermediate results (after 7th iteration)
    2 3 5 7
    11 13 17 19
    23 29
    31 37
    Final results
    2 3 5 7 11 13 17 19 23 29
    31 37
    How to write this code ?
    Please Help me!
    Thank you so muchhh ?????

    h2. {color:#ff0000}Multiplepost{color}
    Replies here: http://forum.java.sun.com/thread.jspa?threadID=5241012&tstart=0
    There is a useful answer the original thread. Answer it, or ignore it as you like, but don't create multiple threads.

  • How to write a SQL query in SAP B1 2007 B with input parameters?

    How to write a SQL query in SAP B1 2007 B with input parameters, on execution of which will ask for some input value from the user and the values will be selected from a list such as item list?

    The syntax like
    SELECT * FROM OITM T0 WHERE T0.ItemCode = '[%0\]'
    Thanks,
    Gordon

  • How to write this query to filter combination of few values

    Hi,
    I have a table CHIMM which is a transaction table and contains information of the vaccines given to a child.
    columns are: child_id, vacc_id, vacc_given_dt. I have to query for remaining vaccines.
    HEXA is a vaccine_id which is composite vaccine of DPT1,POL1,HBV1 & HIB1 (vaccine ids).
    I want to write to query if any of DPT1,POL1,HBV1 & HIB1 given then HEXA should not be displayed in the result.
    OR
    if HEXA is given then of course any of DPT1,POL1,HBV1 & HIB1 should not be displayed in the result.
    How to write this query?
    Regards

    Hi,
    I'm still not sure what the output you want from that sample data is. Do you just want the child_ids, like this
    CHILD_ID
           3
           4? If so, here's one way to get them:
    WITH     all_vacc_ids     AS
         SELECT     c.child_id
         ,     c.vacc_id          AS child_vacc_id
         ,     v.vacc_id
         ,     COUNT ( CASE
                             WHEN  c.vacc_id = 'HEXA'
                       THEN  1
                         END
                    )       OVER ( PARTITION BY  c.child_id
                                       )    AS hexa_itself
         FROM          vacc   v
         LEFT OUTER JOIN     chimm  c     PARTITION BY (c.child_id)
                          ON     c.vacc_id     = v.vacc_id
         WHERE   v.vacc_desc       = 'HEXA'     -- See note below
    SELECT       child_id
    FROM       all_vacc_ids
    WHERE       child_vacc_id     IS NULL
      AND       vacc_id     != 'HEXA'
      AND       hexa_itself     = 0
    GROUP BY  child_id
    rha2 wrote:there are alot of vaccines, i just put 3 for example. this query gives error: invalid relational operatorAre you saying that the vacc table contains other rows, but those other rows are not needed for this problem? It would be good if you included an example in the sample data. The query above considers only the rows in vacc where vacc_desc='HEXA'. You can have other rows in the vacc table, but they won't affect the output of this query. The query above makes no assumptions about the number of rows that have vacc_desc='HEXA'; it will report all child_ids who are missing any of them, regardless of the number (assuming the child does not have the 'HEXA' vacc_id itself, like child_id=1).
    You still haven't said which version of Oracle you're using. The query above will work in Oracle 10 (and higher).

Maybe you are looking for

  • My iPhone 5 is suddenly having audio issues through the headphone jack.

    So this is a strange situation, and I'll try to explain in depth so that someone might be able to suggest a solution. As reference, I have an iPhone 5 that I purchased in late-February. I've had every other model of iPhone except for the first iPhone

  • Conditionally Required Fields

    Basics - Running LC ES 8.2 and Acrobat 9 Pro and using Acrobat for this form. Novice/Beginner in JavaScripting as a whole, especially as pertains to PDFs Situation - Trying  to set up a form wherein a field is required if one option from a combo  box

  • Post XML over HTTPS

    We are trying to do the following. Can anyone help by providing any pointers as how to do it. 1. A java client will be posting XML over http(s) to the Tomcat server. 2. The Tomcat server has to do the following: - Validate the user credentails and ve

  • Adobe Acrobate 7.0 Standard Failed activation !!

    Hello Support Team, Please we have a license for acrobat reader 7 standard, but we got activation required message and after 2 Min program exit. Please find attached all Pic. describing the error messages. If you have any questions please let us now.

  • POWL-Feeder-Class is called twice by class CL_POWL_MODEL

    Hi all, we are running sap erecruiting and there's an application called "dashboard" that uses the POWL-Technologie. Now we noticed, that our feeder class is called twice when one particular "query" is called via dashboard: once within method "handle