Need Help in Select Statement

Dear gurus
Below is my select statement. Im having problem with statement.
the problem is that  the table vbfa  have some entries like this
800     1400004654     10     3900012235     10     M     424,672.68
800     1400004654     10     3900012257     10     M     137,093.36
800     1400004654     20     3900012311     20     M     214,257.36
800     1400004654     30     3900012412     30     M     81,248.44
800     1400004654     30     3900012901     30     M     166,920.68
When the select statement is run it does not fetch the data of LINE number 2 and Line number 5
LOOP AT itab1.
    SELECT SINGLE * INTO CORRESPONDING FIELDS OF wa_vbfa
    FROM vbfa
    WHERE vbelv = itab1-vgbel
    AND posnn = itab1-vgpos
    AND vbtyp_n = 'M'.
    SELECT SINGLE * INTO CORRESPONDING FIELDS OF wa_vbrk
      FROM vbrk
      WHERE vbeln = wa_vbfa-vbeln
      AND vbtyp = 'M'.
    IF sy-subrc = 0.
        itab1-lfimg = wa_vbfa-rfmng.
       itab1-old_price = wa_vbfa-rfwrt.
       MODIFY itab1.
       ELSE.
    ENDIF.
  ENDLOOP.
Please Help
Regards
Saad Nisar

Hello Saad,
The reason why you are not getting the 2nd and 5th entries is that, the where conditions vbelv, posnn and vbtyp_n matches for both the 1st and 2nd record where select will pick only the 1st record. The same way for 4th and 5th record. so its picking only 4th.
So to avoid this add even vbeln in the where condition of the select query
LOOP AT itab1.
    SELECT SINGLE * INTO CORRESPONDING FIELDS OF wa_vbfa
    FROM vbfa
    WHERE vbelv = itab1-vgbel
    AND posnn = itab1-vgpos
   AND vbeln = itab1-field           " Add the corresponding field here
    AND vbtyp_n = 'M'.
    SELECT SINGLE * INTO CORRESPONDING FIELDS OF wa_vbrk
      FROM vbrk
      WHERE vbeln = wa_vbfa-vbeln
      AND vbtyp = 'M'.
    IF sy-subrc = 0.
        itab1-lfimg = wa_vbfa-rfmng.
       itab1-old_price = wa_vbfa-rfwrt.
       MODIFY itab1.
       ELSE.
    ENDIF.
  ENDLOOP.
Vikranth

Similar Messages

  • Need help regarding SELECT statement

    Hello, first time here but need help badly.
    I been using SQL syntax with another SQL server by the following statement doesnt seem to work in Oracle database.
    SELECT firstname+" "+lastname AS fullname FROM customers
    basicially, I just want to display date from two column as one column.
    Thanks

    Oracle has pipe sign for concate
    SELECT firstname||' '||lastname AS fullname
    FROM customers;Khurram

  • Need help on select statement...

    Hi,
    I need to fetch from vbfa table those records where vbeln starts with '0800'.
    my select statement given below gives a syntax error..pl help.
    SELECT * FROM vbfa WHERE vbeln(4) = '0800'.
    vbeln(4) is not accepted and i get the message ' field vbeln(4) is unknown' ...what to do?
    thks

    Use LIKE. Please see F1 on this.
    Rob
    (changed CP to LIKE)
    Edited by: Rob Burbank on Sep 15, 2008 11:18 AM

  • Need help with select statement or query

    Not familiar with what to call it, but here is what i need...
    To give our analyst a better idea of warranty on some of our
    equipment, i
    would like to add to the page a column that displays if the
    device is still
    under warranty
    I currently capture the date the equipment was returned from
    repair, so what
    could i use within my select statement or query to display a
    warranty
    expiration date or display on the page...
    example :
    Returned from repair 10/20/2006 warranty expires on
    11/20/2006
    each equipment has different warranties, so i need a formula
    or something to
    say... device #1 has 60 day warranty ( so 10/20/2006 + 60days
    =
    12/19/2006 )
    I would imagine this to be a query
    Table 1 would contain the equipment type and warranty time
    Table 2 would contain the current status of the equipment
    Query would take the back from repair date + warranty =
    expiration date

    Simple. Join the two tables and create a derived column for
    the expiration date. The exact syntax is dependant on your DBMS, so
    check the manual for whichever you are using and look at the date
    functions. There will be a function that will allow you to add a
    number of date units (day, month, year, etc) to a date
    field.

  • Need help using Select statement  to  retrieve one record

    Hi guys, my first post so be gentle please. The basis of this fucntion is to search my dtabase using the select statement to find the record the user wants, by retrieving the name of theitem from the text box. details are then displayed on a joption message box.
    Everytime I run this program it throws an exception 'Exception: null'. Can anyone see where I am going wrong, I have only bn learning java for thepast 6 months so perhaps I am doing something wrong.
    Or perhaps there is another way for me to close the st, con, rs?
    Your help appreciated
    public void searchproducts(){
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    try{
    //creating and loading a database connection
    String dbUrl = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=db2.mdb;"; // String dbUrl = "jdbc:odbc:people";
    String user = "";
    String password = "";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection c = DriverManager.getConnection(
    dbUrl, user, password);
    int count;
    st = con.createStatement();
    rs = st.executeQuery("SELECT ItemName, Country, Yearmade, ValuePrice, Forsale FROM Collectman WHERE ItemName="+" '"+txtsearchproduct.getText()+"'" );
    while(rs.next()) {
    String ItemName = rs.getString(1);
    String Country = rs.getString(2);
    String Yearmade = rs.getString(3);
    String ValuePrice = rs.getString(4);
    String Forsale = rs.getString(5);
    JOptionPane.showMessageDialog(null, "product details are: " + ItemName + " " + Country + " " + Yearmade + " " + ValuePrice + " " + Forsale);
    //It keeps on throwing this excpetion with null
    catch (Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(rs != null)
    rs.close();
    if(st != null)
    st.close();
    if(con != null)
    con.close();
    } catch (SQLException e) {
    }

    And while we're waiting on that, I'll just say it's nice to see you almost got the general layout of a db call correct...that's a rare thing around here. The finally should have a try/catch round each of the close statements and not around all three in one go. If the resultset throws an exception in your version then you would fail to close either the statement or the connection.
    The second thing is, look up PreparedStatements. They're a better choice for handling SQL requiring variables than using a bog standard Statement.

  • Need help on select statement in ABAP

    Hi,
    I have 2 table. in that I need to do join. But 2 fields of table A that I need to join with the 2 fields in table B.
    But problem is that both the fields of table A can be NULL(either of them).
    i.c.
                          Table A                                                                      Table B
    KONDA     KUNNR      PRICESHEET                                     KONDA       KUNNR
    KA             NULL           A                                                       KA            1000
    KA             NULL           B                                                       KA            1001
    DZ             NULL            C                                                      DZ             1002
    NULL         1000            D                                                       DZ             1003
    NULL         1001            E                                                       DZ             1004
    NULL         1002            F
    NULL         1003            F
    NULL         1004            G
    After Joining I need for KONDA = 'KA'
    KONDA     KUNNR      PRICESHEET 
    KA             NULL           A            
    KA             NULL           B
    NULL         1000            D 
    NULL         1001            E 
    Could you plz help me...Plz reply soon. Thanks in advance
    Regards
    Anutosh

    select a~konda a~kunnr a~pricesheet  from table_a as a
    join table_b as b on ( a~konda = b~konda or a~konda eq space ) and (a~kunnr = b~kunnr or a~kunnr eq space )
    where b~konda = 'KA'.
    Try that
    Edited by: Ramiro Escamilla on Apr 3, 2008 11:48 PM

  • Need help on Select statement/Formula

    Post Author: Krazy Kasper
    CA Forum: Data Connectivity and SQL
    My crystal report (Crystal Reports X) pulls about five thousand records/transactions. When any 2 transactions have every field the same except STATUS, I want to select from those 2 that transaction where STATUS = I.
    Appreciate any help you can provide.
    Krazy
    [email protected]

    Use LIKE. Please see F1 on this.
    Rob
    (changed CP to LIKE)
    Edited by: Rob Burbank on Sep 15, 2008 11:18 AM

  • Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait

    Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait...
    I tried downloading updates like it said to but it still will not display the document.  How do I print the PDF file ASAP

    Can you give us a LOT more info?
    What email client? What version of Reader (I can only assume you even have Reader at this point)?
    Please wait? I'm sure it says more than that, right?
    Have you tried simply saving the PDF (it IS a PDF correct?) to your desktop and opening it from there?
    Did you get this form from the IRS or did it come from somewhere else? If the IRS again, what version of Reader?
    Help us help you.

  • Help needed with a SELECT statement. How can I make it run faster?

    Hi,
    not sure if my brain is just too tired but I can't seem to crack this problem today.
    Here is my scenario.
    I have 2 tables
    TABLE1 (searchId INTEGER, routeId INTEGER);
    TABLE2 (routeId INTEGER, cityId INTEGER);
    There are indexes on all 4 columns.
    (routeId on TABLE1 is a primary key).
    In the data I am using, a given search has more than 500 routes, each route has between 10 and 300 cities among more than 4000 possible different cities.
    Now, what I want to create is the list of route couple, within a certain search, that do not have a single city in common.
    That list should populate a table with the following structure
    TABLE3 (searchId INTEGER, routeId1 INTEGER, routeId2 INTEGER)
    Here is the fastest select statement I have found so far.
    SELECT :searchId, t1.routeId, t2.routeId FROM table1 t1, table1 t2
    WHERE t1.searchId=:searchId AND t2.searchId=:searchId
    AND t1.routeId>t2.routeId
    AND NOT EXISTS (
    SELECT cityId FROM table2
    WHERE routeId=t1.routeId
    INTERSECT
    SELECT cityId FROM table2
    WHERE routeId=t2.routeId);
    But it still seem really slow to me.
    Any suggestion for an improved version is welcome.
    Thanks,
    Martin.
    Title was edited by:
    user453358

    I originaly posted this thread because I tought I was missing something "obvious" that would perform better that would make my SELECT statement perform better.
    So I did not want to go as deep as using TKPROOF yet.
    Here is the statistics I gets on my statement.
      1   SELECT t1.searchId,t1.routeId, t2.routeId id2
      2      FROM table1 t1, table1 t2
      3     WHERE t1.searchid=t2.searchid
      4      AND t1.searchId=91
      5      AND t1.routeId>t2.routeId
      6      AND NOT EXISTS (
      7             SELECT cityId FROM table2
      8              WHERE routeId=t1.routeId
      9             INTERSECT
    10             SELECT cityId FROM table2
    11*            WHERE routeId=t2.routeId)
    SQL> /
    43302 rows.
    Tidsåtgång: 00:01:55.02
    Körschema
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=9 Card=1 Bytes=14)         
       1    0   FILTER                                                             
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=1 Card=1 Bytes=7)                                                
       3    2       NESTED LOOPS (Cost=3 Card=1 Bytes=14)                          
       4    3         TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=2 Card=1 Bytes=7)
       5    4           INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=1 Card=1)                                                    
       6    3         INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=0 Card=1)                                                      
       7    1     INTERSECTION                                                     
       8    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
       9    8         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      10    9           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
      11    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
      12   11         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      13   12           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
    Statistik
              1  recursive calls                                                   
              0  db block gets                                                     
        2872765  consistent gets                                                   
              0  physical reads                                                    
            812  redo size                                                         
         964172  bytes sent via SQL*Net to client                                  
          32245  bytes received via SQL*Net from client                            
           2888  SQL*Net roundtrips to/from client                                 
         860256  sorts (memory)                                                    
              0  sorts (disk)                                                      
          43302  rows processed  Looks like a big number of consistent gets! Any idea how to improve on that?
    Martin.

  • Need Help In SQL Statement

    Hi,
    I need to combine many table only in one select statement.
    This is my table name
    - L20060101
    - L20060102
    - L20060103
    - L20060104
    - L20060105
    - L20060131
    - L20060201
    I dont how to do select statement to select all this table
    This is the wrong select statement.
    Select * from like '%L200601%
    Can i do like that?
    Can any body help me on how to solve my problem?

    You could do something like
    create or replace procedure sp_create_monthly_tabs
         (p_month in varchar2) is
    v_sql varchar2(32767);
    v_cnt number:=0;
    begin
    v_sql := null;
    for c1 in (select table_name from user_tables
    ---   put in the condition to select the tables by the month
    ---  passed in as the parameters
                  ) loop
       if v_cnt = 0 then
          v_sql := 'Create or replace VIEW Mon_Tab'||p_month ||
                       'AS Select * from '||C1.Table_Name ||' ' ;
       else
          v_sql := v_sql||'Union All '||'Select * from '||C1.Table_Name ||' ' ;
       end if;
       v_cnt := v_cnt + 1;
    end loop;
    execute immediate(v_sql)
    end;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help on case statements to validate records

    Hi Experts ,
    My table :
    seq_num
    col2
    col3
    col4
    1
    A
    12345
    P
    2
    B
    1
    123%23
    3
    C
    1
    23AB
    4
    D
    1
    20131001
    5
    E
    1
    6
    A
    13245
    Q
    7
    B
    1
    12345
    8
    C
    2
    1234*AB
    9
    D
    5
    20140112
    10
    E
    1
    00020
    my output
    seq_num
    col2
    col3
    col4
    Status
    Reason
    1
    A
    12345
    P
    Valid
    2
    B
    1
    123%23
    invalid
    Special Character for col4
    3
    C
    1
    23AB
    Valid
    4
    D
    1
    20131001
    Valid
    5
    E
    1
    invalid
    null for col4
    6
    A
    13245
    Q
    invalid
    Invalid character col4 || invalid number for col3
    7
    B
    1
    12345
    Valid
    8
    C
    2
    1234*AB
    Invalid
    Special Character col4 ||invalid col3
    9
    D
    5
    20140112
    invalid
    Future dates col4 ||invalid col3
    10
    E
    1
    00020
    Valid
    Sql :
    with t as
    ( select 1 as seq_num,'A' as col2 ,12345 as col3 ,'P' as col4 from dual
    union all
    select 2 ,'B',1,'123%23' from dual
    union all
    select 3,'C',1,'23AB' from dual
    union all
    select 4,'D',1,'21-02-2013' from dual
    union all
    select 5,'E',1,null from dual
    union all
    select 6,'A,13245,'Q' from dual
    union all
    select 7,'B',1,12345 from dual
    union all
    select 8,'C',2,'1234*AB' from dual
    union all
    select 9,'D',5,'25-01-2014' from dual
    union all
    select 10,'E',1,20 from dual
    I am applying rules on col3 and col4 for each records row-wise.
    I need case statements to populate status and reason columns after applying below rules
    Rules
    Col3 :
    For A record ,it should be 12345 always .
    For B,C,D,E , record should be always 1
    col4
    For A record , it should be either P or R
    No null values for all A, B,C,D,E records
    for B record , it dont contain special charecters
    for C RECORD ,  it dont contain special charecters
    for D record ,it should not contain future dates (dates are in yyyymmdd format and  less than  sysdates are valid )
    I have other columns as well ,as i not included here
    .It would be great if you Could  help on case statements
    Thanks and Regards,
    Sumanth

    I've adjusted Gregs nice example a bit. This should work:
    with w_base as (
          select seq_num, col2, col3, col4,
                 case when (col2 = 'A'                 AND col3 = 12345 )
                        OR (col2 in ('B','C','D','E')  AND col3 = 1)
                            then '' else '||invalid col3' end ||
                 case when (col2 = 'A'        AND col4 not IN ( 'P', 'R' ) )
                            then '||invalid col4' else '' end ||
                 case when (col2 IN ( 'B', 'C' )   AND col4 != translate(col4, 'a!@#$%^*()','a') )
                            then '||special character for col4' else '' end ||
                 case when (col2 = 'D'        AND col4 >= to_char(sysdate,'yyyymmdd') )
                            then '||future dates col4' else '' end
                   reason
          from ( select 1 as seq_num, 'A' as col2, 12345 as col3, 'P' as col4  from dual union all
                 select 2,            'B',         1,             '123%23'     from dual union all
                 select 3,            'C',         1,             '23AB'       from dual union all
                 select 4,            'D',         1,             '20130212'   from dual union all
                 select 5,            'E',         1,             null         from dual union all
                 select 6,            'A',         13245,         'Q'          from dual union all
                 select 7,            'B',         1,             '12345'      from dual union all
                 select 8,            'C',         2,             '1234*AB'    from dual union all
                 select 9,            'D',         5,             '20140125'   from dual union all
                 select 10,           'E',         1,             '20'         from dual )
    Select seq_num, col2, col3, col4,
           case when reason is null then 'Valid' else 'Invalid' end status,
           substr(reason, 3 ) reason
    from w_base
    It returns
    SEQ_NUM
    COL2
    COL3
    COL4
    STATUS
    REASON
    1
    A
    12345
    P
    Valid
    2
    B
    1
    123%23
    Invalid
    special character for col4
    3
    C
    1
    23AB
    Valid
    4
    D
    1
    20130212
    Valid
    5
    E
    1
    Valid
    6
    A
    13245
    Q
    Invalid
    invalid col3||invalid col4
    7
    B
    1
    12345
    Valid
    8
    C
    2
    1234*AB
    Invalid
    invalid col3||special character for col4
    9
    D
    5
    20140125
    Invalid
    invalid col3||future dates col4
    10
    E
    1
    20
    Valid
    edited some bugs :) now it should be fine! really

  • Need help with update statement with multiple joins

    I've got the following select statement that is pulling 29 records:
    SELECT
    PPA.PROJECT_ID,
    PPA.SEGMENT1,
    peia.expenditure_item_id,
    peia.expenditure_type,
    pec.expenditure_comment
    FROM PA.PA_PROJECTS_ALL PPA,
    pa.pa_expenditure_items_all peia,
    pa.pa_expenditure_comments pec
    where PPA.segment1 < '2008' and
    PPA.project_id = 52 and -- just run for project # 20077119 for testing
    peia.expenditure_type = 'PAYROLL' and
    peia.project_id = ppa.project_id and
    PEC.EXPENDITURE_ITEM_ID = PEIA.EXPENDITURE_ITEM_ID;
    I need to update the pec.expenditure_comments to a static field for those 29 records. I assume I should start with the following, but not sure how to complete the where:
    update
    pa.pa_expenditure_comments pec
    set pec.expenditure_comment = 'REFERENCE HD#728'
    where
    First time that we've ever needed to update, so any and all help appreciated.

    Try using exists:
    update pa.pa_expenditure_comments pec
    set    pec.expenditure_comment = 'REFERENCE HD#728'
    where exists ( select null
                   from   pa.pa_projects_all ppa
                   ,      pa.pa_expenditure_items_all peia
                   ,      pa.pa_expenditure_comments pec2
                   where  ppa.segment1 < ''    -- not sure what you posted here, so for next time:
                                               -- please put your examples between the code tags.
                   and    ppa.project_id = 52  -- just run for project # 20077119 for testing
                   and    peia.expenditure_type = 'PAYROLL'
                   and    peia.project_id = ppa.project_id
                   and    pec2.expenditure_item_id = peia.expenditure_item_id
                   and    pec2.expenditure_item_id = pec.expenditure_item_id
                 );

  • Need Help On SQL Statement

    I am using Sybase as my back end database. I need help on my SQL statement regarding datetime. The datetime is store as a 9 digit integer in the database (...I believe it is a Decimal(30,6) format, let me know if I am wrong).
    If I do this, "select * from mytable;" It works out fine (except I don't know what the date means e.g. 998919534)
    If I do this, "select * from mytable where datetime_col < '9/5/2002' ; I got an error. I even tried '9/5/02 11:00 000 am' but it didn't help.
    How do I specify a date or datetime in my query?
    Thanks in advance.

    I execute the sql statement
    select * from mytable where datetim_col < convert(datetime, '3/4/2002', 101) ;
    I got mix result. I got an error message "cannot convert 10375584 to a date.
    Yet, he statistics window of the I-sql says
    "estimated 493 rows in query (I/O estimate 87)
    PLan> mytable (seq)"
    It looks like I my the SQL statement is correct and then the system can't display it in the Data window.
    Any thought ?

  • Need help for sql statement

    Hi,
    Need help to write sql statement.
    create table t_dt ( dt_start date, dt_end date, amount number);
    insert into t_dt values('1-Jan-10','10-Feb-10',12);
    insert into t_dt values('11-Feb-10','10-Mar-10',10);
    insert into t_dt values('11-Mar-10','20-Apr-10',8);
    insert into t_dt values('21-Apr-10','28-Jun-10',10);
    insert into t_dt values('29-Jun-10','20-Sep-10',10);
    insert into t_dt values('21-Sep-10','10-Oct-10',10);
    insert into t_dt values('11-Oct-10','31-Dec-10',8);
    insert into t_dt values('1-Jan-11','10-Feb-11',8);
    insert into t_dt values('11-Feb-11','10-Mar-11',7);
    insert into t_dt values('11-Mar-11','20-Apr-11',6);
    insert into t_dt values('21-Apr-11','28-Jun-11',6);
    insert into t_dt values('29-Jun-11','20-Sep-11',6);
    insert into t_dt values('21-Sep-11','10-Oct-11',4);
    insert into t_dt values('11-Oct-11','31-Dec-11',8);
    Result should be like below..
    dt_start     dt_end     Amount
    1-Jan-10     10-Feb-10     12
    11-Feb-10     10-Mar-10     10
    11-Mar-10     20-Apr-10     8
    21-Apr-10     10-Oct-10     10
    11-Oct-10     10-Feb-11     8
    11-Feb-11     10-Mar-11     7
    11-Mar-11     20-Sep-11     6
    21-Sep-11     10-Oct-11     4
    11-Oct-11     31-Dec-11     8
    Just to explain the example, take a row with start date as 21-Apr-10 in the above insert statements, since it has the same amount for next two rows (i.e. with start date '29-Jun-10' and '21-Sep-10') these 3 rows should be converted to represent only 1 row in the result and the start date and end date should be changed per the result shown above.
    Thanks.

    Hello
    I think this gives yuo what you need....
    SELECT
        MIN(dt_start),
        MAX(dt_end),
        amount
    FROM
        (   SELECT
                dt_start,
                dt_end,
                MAX(marker) OVER(ORDER BY dt_start) marker,
                amount
            FROM
                    Select
                        dt_start,
                        dt_end,
                        amount,
                        CASE
                            WHEN LAG(amount) OVER(ORDER BY dt_start) <> amount THEN
                                ROW_NUMBER() OVER(ORDER BY dt_start)
                        END marker
                    from t_dt
    GROUP BY
         amount,
         marker
    order by     
         MIN(dt_start)
    MIN(DT_START)        MAX(DT_END)              AMOUNT
    01-JAN-2010 00:00:00 10-FEB-2010 00:00:00         12
    11-FEB-2010 00:00:00 10-MAR-2010 00:00:00         10
    11-MAR-2010 00:00:00 20-APR-2010 00:00:00          8
    21-APR-2010 00:00:00 10-OCT-2010 00:00:00         10
    11-OCT-2010 00:00:00 10-FEB-2011 00:00:00          8
    11-FEB-2011 00:00:00 10-MAR-2011 00:00:00          7
    11-MAR-2011 00:00:00 20-SEP-2011 00:00:00          6
    21-SEP-2011 00:00:00 10-OCT-2011 00:00:00          4
    11-OCT-2011 00:00:00 31-DEC-2011 00:00:00          8
    9 rows selected.HTH
    David
    Edited by: Bravid on Feb 23, 2012 12:08 PM
    Beaten to it by Frank! :-)

  • Need help on SQL Statement for UDF

    Hi,
    as I am not so familiar with SQL statements on currently selected values, I urgently need help.
    The scenario looks as follows:
    I have defined two UDFs named Subgroup1 and Subgroup2 which represent the subgroups dependent on my article groups. So for example: When the user selects article group "pianos", he only sees the specific subgroups like "new pianos" and "used pianos" in field "Subgroup1". After he has selected one of these specific values, he sees only the specific sub-subgroups in field "Subgroup2", like "used grand pianos".
    I have defined UDTs for both UDFs. The UDT for field "Subgroup1" has a UDF called "ArticleGroup" which represents the relation to the article group codes. The UDT for field "Subgroup2" has a UDF called "Subgroup1" which represents the relation to the subgroups one level higher.
    The SQL statement for the formatted search in field "Subgroup1" looks as follows:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP1]  T0 WHERE T0.[U_ArticleGroup]  = (SELECT $[OITM.ItmsGrpCod])
    It works fine.
    However, I cannot find the right statement for the formatted search in field "Subgroup2".
    Unfortunately this does NOT WORK:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP2]  T0 WHERE T0.[U_Subgroup1]  = (SELECT $[OITM.U_Subgroup1])
    I tried a lot of others that didn't work either.
    Then I tried the following one:
    SELECT T0.[Name] FROM [dbo].[@B_SUBGROUP2]  T0 WHERE T0.[U_Subgroup1] = (SELECT T1.[Code] FROM [dbo].[@B_SUBGROUP1] T1 WHERE T1.[U_ArticleGroup] = (SELECT $[OITM.ItmsGrpCod]))
    Unfortunately that only works as long as there is only one specific subgroup1 for the selected article group.
    I would be sooooo happy if there is anyone who can tell me the correct statement for my second UDF!
    Thanks so much in advance!!!!
    Edited by: Corinna Hochheim on Jan 18, 2010 10:16 PM
    Please ignore the "http://" in the above statements - it is certainly not part of my SQL.
    Please also ignore the strikes.

    Hello Dear,
    Use the below queries to get the values:
    Item Sub Group on the basis of Item Group
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP]  T0 WHERE T0.[U_GroupCod] =$[OITM.ItmsGrpCod]
    Item Sub Group 1 on the basis of item sub group
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP1]  T0 WHERE T0.[U_SubGrpCod]=(SELECT T0.[Code] FROM [dbo].[@SUBGROUP]  T0 WHERE T0.[Name] =$[OITM.U_ItmsSubgrp])
    Sub group 2 on the basis of sub group 1
    SELECT T0.[Name] FROM [dbo].[@SUBGROUP2]  T0 WHERE T0.[U_SubGrpCod1]=(SELECT T0.[Code] FROM [dbo].[@SUBGROUP1]  T0 WHERE T0.[Name] =$[OITM.U_ItmsSubgrp1])
    this will help you.
    regards,
    Neetu

Maybe you are looking for

  • Message not delivered

    I have an Iphone 4 and sometimes when I send a text I get the message it was not delivered.  When I press the ! it gives me a couple of options and one is to send as a text message.  I select that and it sends the message.  Anyone have that issue and

  • Low value asset error at the time of goods receipt (MIGO)

    Hi I am testing the FI MM integration - Asset acquisition through PO. I created a PR and a PO for Laptop @ rs. 200000 At the time of posting goods receipt I am getting the following error: Total value per quantity should be more than 5000 in this cla

  • Add multiple objects to a Deque to be retrieved in that order?

    All: We are using a LinkedBlockingDeque in a classic producer/consumer setup -- multiple threads may post "commands" to the Q, and the consumer retrieves and executes each command in a separate thread. We have very rare cases where we need to post mo

  • International characters insanity! Help!

    Hello, Here's a very strange situation I have to deal with. Let's say I write a text using international characters (in French, for example) on my MacBook (OS X 10.5, if it matters), using TextEdit in plain text format. I can save, close, reopen, ope

  • Lightroom 64 bit is closing down

    " Windows detected a problem with the program Adobe Photoshop Lightroom 3. Click OK to close the program. The next time the program launches it will automatically open in compatibility mode" I got the above message about two days after downloading th