Doubt in select stmnt

Hi,
I created a new table 'STUD' with columns 'STUD_NO','STUD_NAME' and 'FEES' in it.
I inserted the data
insert into stud values (001,'xxxx',2000);
insert into stud values (002,'yyyy',3000);
when I selecting the data using SELECT statement...
it is retreving as
STUD_NO STUD_NAME FEES
1 xxxx 2000
2 yyyy 3000
my question is I inserted it the way as '001' but I am retreiving it as '1'......
Is there any way that I can retreive the data the same way(001) I have entered for STUD_NO column.
Means i need to get it as '001' only...
Can anyone please solve this.
Thanks in advance.

Here if we see we are not directly retreving the same way as it from table.
we are formating it to 'FM000' means limited to three numerics as we know that it is 001.
But if I dont know exact value as above and still I want to retreive the sameway as it is from databse.
Is there otherway to do this.
Here I have given the value as 001 and u have mentioned it to give as 'FM000'.
But If I dont know the value and still I want to select the data as it is how I can do.
Thanks in advance.

Similar Messages

  • Doubt in 'SELECT-CASE'

    I have a doubt in 'SELECT-CASE'. There is this example of which i have :-
    SELECT /*+ rule */ SUM(CASE WHEN age <= 15 THEN cnt ELSE 0 END) "upto 15 Years" ,
    SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
    SUM(CASE WHEN age >= 21 AND age <= 25 THEN cnt ELSE 0 END) "21-25 Years" ,
    SUM(CASE WHEN age >= 26 AND age <= 30 THEN cnt ELSE 0 END) "26-30 Years" ,
    SUM(CASE WHEN age >= 31 AND age <= 35 THEN cnt ELSE 0 END) "31-35 Years" ,
    SUM(CASE WHEN age >= 36 AND age <= 40 THEN cnt ELSE 0 END) "36-40 Years" ,
    SUM(CASE WHEN age >= 41 AND age <= 45 THEN cnt ELSE 0 END) "41-45 Years" ,
    SUM(CASE WHEN age >= 46 AND age <= 50 THEN cnt ELSE 0 END) "46-50 Years" ,
    SUM(CASE WHEN age >= 51 AND age <= 55 THEN cnt ELSE 0 END) "51-55 Years" ,
    SUM(CASE WHEN age >= 56 AND age <= 60 THEN cnt ELSE 0 END) "56-60 Years" ,
    SUM(CASE WHEN age >= 61 AND age <= 65 THEN cnt ELSE 0 END) "61-65 Years" ,
    SUM(CASE WHEN age >= 66 AND age <= 70 THEN cnt ELSE 0 END) "66-70 Years" ,
    SUM(CASE WHEN age > 70 THEN cnt ELSE 0 END) ">70 Years"
    FROM
    (SELECT /*+ rule */ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) age,COUNT(1) cnt
    FROM contract_all co , customer_all ca ,curr_co_status curr
    WHERE ca.customer_id = co.customer_id
    AND co.co_id = curr.co_id
    AND curr.ch_status = 'a'
    AND ca.birthdate IS NOT NULL
    --AND    co.co_activated BETWEEN '01-jan-2004' AND  '31-dec-2004'
    AND EXISTS ( SELECT 'x' FROM hss_cust_segment hcs
    WHERE hcs.prgcode = ca.prgcode
    AND hcs.description = 'POST')
    GROUP BY ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12))
    In this the statements on top like this-
    SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
    how does the increment happen in 'THEN cnt' because we are not doing the increment as such using '+1' kind of thing.
    I hope, my question is clear. Please help in solving the doubt.
    Regards.

    Sample data, wrong output and desired output please...
    I tried with this and it seems right...
    WITH ca as (
      select to_date('26-9-1990') birthdate from dual union all
      select to_date('26-9-1989') birthdate from dual union all
      select to_date('26-9-1974') birthdate from dual
    SELECT /*+ rule */ SUM(CASE WHEN age <= 15 THEN cnt ELSE 0 END) "upto 15 Years" ,
      SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
      SUM(CASE WHEN age >= 21 AND age <= 25 THEN cnt ELSE 0 END) "21-25 Years" ,
      SUM(CASE WHEN age >= 26 AND age <= 30 THEN cnt ELSE 0 END) "26-30 Years" ,
      SUM(CASE WHEN age >= 31 AND age <= 35 THEN cnt ELSE 0 END) "31-35 Years" ,
      SUM(CASE WHEN age >= 36 AND age <= 40 THEN cnt ELSE 0 END) "36-40 Years" ,
      SUM(CASE WHEN age >= 41 AND age <= 45 THEN cnt ELSE 0 END) "41-45 Years" ,
      SUM(CASE WHEN age >= 46 AND age <= 50 THEN cnt ELSE 0 END) "46-50 Years" ,
      SUM(CASE WHEN age >= 51 AND age <= 55 THEN cnt ELSE 0 END) "51-55 Years" ,
      SUM(CASE WHEN age >= 56 AND age <= 60 THEN cnt ELSE 0 END) "56-60 Years" ,
      SUM(CASE WHEN age >= 61 AND age <= 65 THEN cnt ELSE 0 END) "61-65 Years" ,
      SUM(CASE WHEN age >= 66 AND age <= 70 THEN cnt ELSE 0 END) "66-70 Years" ,
      SUM(CASE WHEN age > 70 THEN cnt ELSE 0 END) ">70 Years"
    FROM ( SELECT /*+ rule */ ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) age, COUNT(1) cnt
           FROM ca
           GROUP BY ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) )
    upto 15 Years          16-20 Years            21-25 Years            26-30 Years            31-35 Years            36-40 Years            41-45 Years            46-50 Years            51-55 Years            56-60 Years            61-65 Years            66-70 Years            >70 Years             
    0                      2                      0                      0                      1                      0                      0                      0                      0                      0                      0                      0                      0                     
    1 rows selectedNH.

  • Doubt in selection screen

    Hi i have a doubt in selection screen I had given statement as below now i can see the output screen and i'm getting the output also now i want to know the value of only one vendor. If i had given a vendor number it must select the particular data of that vendor only can u give me any suggestions please
    SELECTION-SCREEN BEGIN OF BLOCK P WITH FRAME TITLE TEXT-000.
          PARAMETERS: VENDORNO like EKKo-LIFNR,
                      PURORG like EKKO-EKORG,
                      PLANT like EKPO-WERKS,
                      PURDOC like EKKO-BEDAT.
    SELECTION-SCREEN END OF BLOCK P.

    Hi Pavan,
    <b>I think this is what u required when u select vendor number automatically for that particular vendor u require values in the remaining 3 parameter fields.
    </b>
    REPORT zex31 .
    PARAMETERS: vendorno LIKE ekko-lifnr,
                      purorg LIKE ekko-ekorg,
                      plant LIKE ekpo-werks,
                      purdoc LIKE ekko-bedat.
    DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.
    DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR vendorno.
      CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
           EXPORTING
                tabname           = 'EKKO'
                fieldname         = 'LIFNR'
                dynpprog          = sy-cprog
                dynpnr            = sy-dynnr
                dynprofield       = 'VENDORNO'
           TABLES
                return_tab        = return
           EXCEPTIONS
                field_not_found   = 1
                no_help_for_field = 2
                inconsistent_help = 3
                no_values_found   = 4
                OTHERS            = 5.
      BREAK-POINT.
      REFRESH dynfields.
      READ TABLE return WITH KEY fieldname = 'VENDORNO'.
    Add it back to the dynpro.
      dynfields-fieldname = return-retfield.
      dynfields-fieldvalue = return-fieldval.
      APPEND dynfields.
    Get the company code from db and add to dynpro
      DATA: xekko TYPE ekko,
            xekpo TYPE ekpo.
      CLEAR xekko.
      CLEAR xekpo.
      SELECT SINGLE * INTO xekko
      FROM ekko
      WHERE lifnr = return-fieldval.
      dynfields-fieldname = 'PURORG'.
      dynfields-fieldvalue = xekko-ekorg.
      APPEND dynfields.
      dynfields-fieldname = 'PURDOC'.
      dynfields-fieldvalue = xekko-bedat.
      APPEND dynfields.
      SELECT SINGLE * INTO xekpo
       FROM ekpo
       WHERE ebeln = xekko-ebeln.
      dynfields-fieldname = 'PLANT'.
      dynfields-fieldvalue = xekpo-werks.
      APPEND dynfields.
    Update the dynpro values.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
           EXPORTING
                dyname     = sy-cprog
                dynumb     = sy-dynnr
           TABLES
                dynpfields = dynfields
           EXCEPTIONS
                OTHERS     = 8.
    START-OF-SELECTION.

  • Doubts in Select query

    Hai,
    I have problem in my select query,
    My previous select query:
      SELECT  rrcty 
            ryear 
            rbukrs
            rzzpspid 
            SUM( hslvt )
            SUM( hsl01 )
            SUM( hsl02 )
            SUM( hsl03 )
            SUM( hsl04 )
            SUM( hsl05 )
            SUM( hsl06 )
            SUM( hsl07 )
            SUM( hsl08 )
            SUM( hsl09 )
            SUM( hsl10 )
            SUM( hsl11 )
            SUM( hsl12 )
            SUM( mslvt )
            SUM( msl01 )
            SUM( msl02 )
            SUM( msl03 )
            SUM( msl04 )
            SUM( msl05 )
            SUM( msl06 )
            SUM( msl07 )
            SUM( msl08 )
            SUM( msl09 )
            SUM( msl10 )
            SUM( msl11 )
            SUM( msl12 )
             FROM zzsl5t
           INTO TABLE it_erbproj
             WHERE rldnr       EQ  c_rldnr        AND
                rrcty      EQ  c_rrcty        AND
                ryear       EQ  v_srr_fyear    AND
                rbukrs      EQ  v_srr_ccode    AND
                racct      EQ  v_racct        AND
                rzzpspid  IN r_zzpspid         
             GROUP BY  RRCTY ryear RBUKRS rzzpspid.
    now i want change the above select query as,
    If user enters input period 03 means,
    i have to select
    SELECT  rrcty 
            ryear 
            rbukrs
            rzzpspid 
            SUM( hslvt )
            SUM( hsl01 )
            SUM( hsl02 )
            SUM( hsl03 )
            SUM( mslvt )
            SUM( msl01 )
            SUM( msl02 )
            SUM( msl03 )
    only, not to select all the periods.
    how can i give fields dynamically.
    please suggest me.
    Elamaran

    Duplicate message. Please close this one and look at my answer Doubt in Select query.

  • Does this select stmnt is supported by non unicode system?

    hi all,
    does this select stmnt is supported by non unicode system?
    SELECT * FROM DD02L INTO TABLE I_TABL
                            WHERE TABNAME IN S_TABL
                            AND   AS4LOCAL = 'A'.
    this  select stmnt is going for dump in 4.6.
    pls help me....
    regards,
    sri sri.

    Hi,
    It's working fine in both (unicode and non-unicode) systems,
    TABLES: dd02l.
    SELECT-OPTIONS:
      s_name FOR dd02l-tabname.
    DATA:
      w_tabl TYPE dd02l,
      i_tabl LIKE TABLE OF w_tabl.
    SELECT *
      FROM dd02l
      INTO TABLE i_tabl
    WHERE tabname IN s_name
       AND as4local = 'A'.
    LOOP AT i_tabl INTO w_tabl.
      WRITE:/
        w_tabl-tabname,
        w_tabl-tabclass.
    ENDLOOP.
    Regards
    Adil
    Edited by: Syed  Abdul Adil on Jun 18, 2008 12:39 PM

  • Faster to replace numerous Select stmnts with indv calls to functions.

    I'm trying to streamline a package that contains many select statements that are just checking for a row return > 0. The tests performed after the "select into v_var" statements are just IF v_var > 0 THEN ...'move on to the next SELECT stmnt'.
    Would it be faster if I moved these select statements out to individually called functions that would return a BOOLEAN value or would the call to a function just slow processing down even more instead? The functions would be part of the same package of course.

    I have said it before, and quite recently too, that counting records is about the worst way to determine existence. If you only care that a record exists, you should do it something like:
    BEGIN
       SELECT 1 INTO v_exists_ha_ss
       FROM associate_assignments aa, associate_office_records aor,
            assoc_sched_set_hme_asmnts assha, assoc_sched_set_ha_details asshd
       WHERE aa.associate_office_record_id = i.aor_id and
             aa.associate_office_record_id = aor.associate_office_record_id and
             aor.associate_office_record_id = assha.associate_office_record_id and
             assha.assoc_sched_set_hme_asmnt_id = v_assocaiterotationweekid and
             assha.assoc_sched_set_hme_asmnt_id = asshd.assoc_sched_set_hme_asmnt_id and
             aa.is_home_assignment = 'Y' and
    rownum = 1;
             <<do whatever you do after setting v_chk := TRUE;>>
    EXCEPTION
       WHEN NO_DATA_FOUND THEN
          -- 1. No HA, so log it as an error
          Pkg_Pre_Sched_Audit.ins_pre_sched_audit(pin_office_id, i.aor_id,
                                                  pin_sched_week_id, 1);
          Pkg_Pre_Sched_Audit.ins_pre_sched_audit(pin_office_id, i.aor_id,
                                                  pin_sched_week_id, 2);
          v_chk := FALSE;
    END;Minimally, you need to restrict it to only one row, and by returning a constant, you have a better chance that the optimizer can avoid table accesses altogether.
    It might be neater to encapsulate the query in a function, particularly if you call the same query at multiple places in the code. If you do encapsulate the query in a function. the function should look something like:
    FUNCTION exists_ha_ss(pin_aor_id IN NUMBER) RETURN BOOLEAN IS
       v_exists_ha_ss NUMBER;
    BEGIN
       SELECT 1 INTO v_exists_ha_ss
       FROM associate_assignments aa, associate_office_records aor,
            assoc_sched_set_hme_asmnts assha, assoc_sched_set_ha_details asshd
       WHERE aa.associate_office_record_id = i.aor_id and
             aa.associate_office_record_id = aor.associate_office_record_id and
             aor.associate_office_record_id = assha.associate_office_record_id and
             assha.assoc_sched_set_hme_asmnt_id = v_assocaiterotationweekid and
             assha.assoc_sched_set_hme_asmnt_id = asshd.assoc_sched_set_hme_asmnt_id and
             aa.is_home_assignment = 'Y' and
             rownum = 1;
       RETURN TRUE;
    EXCEPTION
       WHEN NO_DATA_FOUND THEN
          RETURN FALSE;
    END;and, unless you expect the query to fail in the vast majority of cases, then I would call it more like:
    v_chk := pkg_pre_sched_audit.exists_ha_ss(pin_aor_id);
    IF v_chk THEN
       << Do your processing >>
    ELSE
      <<log the errors>>
    END IF;and, if you don't actually need v_chk antwhere else, you could even do:
    IF pkg_pre_sched_audit.exists_ha_ss(pin_aor_id);
       << Do your processing >>
    ELSE
      <<log the errors>>
    END IF;HTH
    John

  • Doubt in select

    hai gurus
    i have a doubt
    i have a select statement like this
    select count(*) into var from emp;
    i want to store it into variable.it giving some error;
    please give some ideas
    thanks

    .it giving some error;
    please give some ideasHere's an idea. Why don't you cut and paste the code from the session in which you're running. Then we can see the error message it throws and perhaps solve your problem for you.
    If you don't give us sufficient details we can't help you. End of.
    Cheers, APC

  • Doubt about Select statement.

    Hi folks!!
                 I have a few doubts about the select statements, it may be a silly things but its useful for me.
    what is   difference between below statment.
    1)SELECT * FROM TABLE.
    2)SELECT SINGLE * FROM TABLE
    3)SELECT SINGLE FROM TABLE.
    Hope i will get answer,thanks in advance.
    Regards
    Richie..

    Hi,
    try this and if possible use sap help.i mean place the cursor on select and press F1.
                 Types of select statements:
    1.     select * from ztxlfa1 into table it.
                 This is simple select statement to fetch all the data of db table into internal table it.
       2.   select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
            Thisis using where condition between v2 and v5.
      4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
      5. select lifnr land1 from ztxlfa1
            into corresponding fields of it   "notice 'table' is omitted
             where land1 = 'DE'.
              append it.
               endselect.
         Now data will go into work area. and then u will add it to internal table by     
            append statement.
      6.   Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
    Table 13.2  Various Forms of SELECT when Filling an Internal Table
    Statement(s)                                   Writes To
    select into table it                                    Body
    select into corresponding fields of table it   Body
    select into it                                    Header line
    select into corresponding fields of it           Header line
    7. SELECT VBRK~VBELN
           VBRK~VKORG
           VBRK~FKDAT
           VBRK~NETWR
           VBRK~WAERK
           TVKOT~VTEXT
           T001~BUKRS
           T001~BUTXT
        INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
        FROM VBRK
        INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
        INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
        WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
       AND VBRK~FKDAT in date.
    Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
    8. SELECT T001W~NAME1 INTO  TABLE IT1_T001W
    FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
    WHERE EKPO~EBELN = PURORD.
    here selecting a single field into table it1_t001winner join on ekpo.
    9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE     EBELN IN P_O_NO.
    ENDSELECT.
    SELECT BUTXT   FROM T001 INTO  IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
    ENDSELECT.
    APPEND IT_T001.
    here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
    10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
                 FROM  VBRK AS A
                 INNER JOIN TVKOT AS B ON
                 AVKORG EQ BVKORG
                 INNER JOIN T001 AS C ON
                 ABUKRS EQ CBUKRS
                 WHERE  AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
                 SY-LANGU
                 AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
                VBRP WHERE VBRP~MATNR EQ ITEMS ).
        Here we are using sub query in inner join specified in brackets.
    Thanks,
    chandu.

  • Doubt on selection-screen

    Hi gurus,
    I done one report to get the Purchase order details. At the time of creating purchase order the users enters a One text field in the Purchase order header text of ME21N transaction. I need to fetch that field into Report. Upto this its fine. I also done this report by using the function module "READ_TEXT". The o/p is also generated successfully.
    But now our client is asking, Please put that text field in selection-screen. Once he presses F4 in that field he needs to display all the values in text field. I know how to do if it is a table field. But it is a purchase order header text. Client enters different text when he creates diferent purchase orders.
      Based on that text field only the report o/p will needs to display.
    For example:
    The User1 creats a Purchase order using ME21N. In that he enters Purchase order header text as ABC.
        when ever he creats a purchase order he enters only ABC.In this way he creats 100 Purchase orders.
      if the user execute the report and in selection screen of that text field , suppose he gives a  ABC, only those 100 purchase orders only needs to appear.
       Like this so many users enters no.of text items. Suppose there are 100 users. totally 100 text values will be there.
        once he presses F4 help on the selecton screen all 100 values need to display. And this is dynamic, the no may increase in future also. thats totally depends on Purcase orders.
    Please guide me how to  do this. 
          Thanks in Advance...
    Thanks and Regards
    Siri........

    hi frnd,
    try like this
    write the logic to fetch text fields into some internal table in
    at selection-screen output event.
    and pass this to selection-option as f4 using ...> call function 'F4IF_INT_TABLE_VALUE_REQUEST'.
    ex
    at selection-screen output.
    use fm "READ_TEXT".  and assign all values to one internal table
    then
    call function 'F4IF_INT_TABLE_VALUE_REQUEST'.
    hope it may help u.
    regards,
    chandu

  • How do I know if SELECT stmnt was issued on a specific Table?

    Hi,
    I have a Reporting environment where the tables get populated by selective information from production database through batch scripts. These tables have become HUGE over time and the management wants to know if any user is using the table or else drop them. A USER will only issue a SELECT command and is not responsible for any INSERT/UPDATE/DELETE so querying the table DBA_TAB_MODIFICATIONS isn't of much help.
    My question is: Is there a way to find out if any of the tables under concern had been queried (using SELECT) in the recent past???
    Thanks in advance!
    Arindam

    Hello,
    Best option is to use fine-grained auditing and once collected information you can drop that policy ; Using full fledged auditing will be an overkill.
    GRANT SELECT ON dba_fga_audit_trail TO <username>;
    grant exexute on dbms_fga to <username>;
    declare
    BEGIN
       DBMS_FGA.add_policy (object_schema => 'SCHEMA_NAME',
                            object_name => 'TABLE_NAME',
                            policy_name => 'TABLE_DML',
                            enable => TRUE,
                            statement_types => 'SELECT',
                            audit_trail => DBMS_FGA,
                            audit_column_opts => DBMS_FGA.any_columns
    END;
    /http://www.oracle-base.com/articles/10g/Auditing_10gR2.php#fine_grained_auditing
    Regards

  • Simple doubt in select statement

    hi all,
    Although this is a very simple ques.
    Can u pl tell me why i m not getting the value into v_adrnr ?
    Chk the following code.
    V_VBELN  = '0080000001'.
      SELECT SINGLE ADRNR
             FROM VBPA
             INTO V_ADRNR
             WHERE VBELN = V_VBELN
             AND   PARVW = 'BP'.
    i have cheked the table vbpa for the above mentioned conditions.I can see the
    value for adrnr in database as 0000022741.
    But while i run the above code i cant see value on v_adrnr.
    Pl help.

    First PARVW has a domain with a conversion routine based on table TPAUM so "BP" is internal code "RE"
    Use CONVERSION_EXIT_PARVW_INPUT
    CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
      EXPORTING
        input = V_PARVW
      IMPORTING
        output = V_PARVW.
    Second
    Have you defined V_VBELN with reference to the element VBELN, char 10 with conversion Alpha
    Then it should work
    Regards

  • Doubt in select statement

    Hi :
    How can i join aufnr , arbei , ismnw since there is no common key field between arbei and aufnr , ismnw.
    I am able to join aufnr and ismnw based on aufnr, because im trying to pull data based on aufnr , but when i went to se84 and tried to chk tables for arbei...only one table HIKO has all these fields but there is no data in that.
    SELECT aaufnr aauart b~arbei INTO CORRESPONDING FIELDS OF TABLE it_tab
    FROM aufk AS a
    INNER JOIN plpo AS b ON awerks = bwerks
    INNER JOIN iloa AS d ON abukrs = dbukrs
    *06/18
    INNER JOIN afko AS e ON aaufnr = eaufnr
    WHERE a~auart IN s_auart
    AND a~auart NE 'PM04'
    AND a~auart NE 'PM09'
    AND a~werks = 'M600'
    AND d~tplnr = 'PB-PRO-S01-BY02-MIL'
    AND d~abckz IN s_abckz
    AND a~erdat IN s_date.
    SELECT SINGLE ismnw INTO v_ismnw FROM afru
    WHERE aufnr = v_aufnr.
    it_tab-ismnw = v_ismnw.
    with my first select statment do i get unique values for arbei?
    i would appreciate if any one can help me on this.
    Thanks.
    Raghu

    Everybody's question is important.
    All you have to do is edit your original question and it will pop to the top.
    If you ask the same question twice, somebody may spend a lot of time trying to answer your question only to find that someone else answered it a long time before.
    Rob

  • Doubt with selection screen

    Hi all!
    I have to show the inspection lot details (QA32) as per the requirements given in the selection screen.
    In my selection screen , I should have select option for Inspection lot created date(QALS-ENSTEHDAT) and lot created time (QALS-ENTSTEZEIT). I would like to know the lots created from yesterday evening till today morning.
    When I give the values 09.02.2008 to 10.02.2008 for date and 17:30:00 to 10:00:00 for time , it'll obviously intimate that 'From- time is greater than To- time'.Is there any way to relate the From-date to From-time and To-date to To-time in the selection screen , so that my problem will be solved.Please help with possible code.
    Edited by: Jayasri P. on Feb 9, 2008 5:55 AM

    Hi,
    try this.........
    TABLES qals.
    DATA it_qals TYPE TABLE OF qals WITH HEADER LINE.
    SELECT-OPTIONS   s_date  FOR  qals-enstehdat  NO-EXTENSION.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN comment (10)   for field  p_timel.
    SELECTION-SCREEN POSITION 35.
    PARAMETERS       p_timel LIKE qals-entstezeit.
    SELECTION-SCREEN comment 54(2)  for field  p_timeh.
    SELECTION-SCREEN POSITION 60.
    PARAMETERS       p_timeh LIKE qals-entstezeit.
    SELECTION-SCREEN END   OF LINE.
    SELECT *
    FROM   qals
    INTO   TABLE it_qals
    WHERE  enstehdat IN s_date.
    IF sy-subrc IS INITIAL.
      SORT it_qals BY enstehdat entstezeit.
      LOOP AT it_qals WHERE enstehdat EQ s_date-low
                      OR    enstehdat EQ s_date-high.
        CASE it_qals-enstehdat.
          WHEN s_date-low.
            IF it_qals-entstezeit LT p_timel.
              DELETE it_qals.
            ENDIF.
          WHEN s_date-high.
            IF it_qals-entstezeit GT p_timeh.
              DELETE it_qals.
            ENDIF.
        ENDCASE.
      ENDLOOP.
    ENDIF.
    LOOP AT it_qals.
      WRITE : / it_qals-enstehdat ,it_qals-entstezeit.
    ENDLOOP.
    also goto selection text and give descriptionas below..
    P_TIMEH     to
    P_TIMEL     Time
    S_DATE     Date
    Cheers,
    jose.

  • Doubt in select [Resolved]

    Hello, I need urgent help
    I have a table where two fields are repeated
    id_terr, resource_id. For example:
    id | id_terr | resource_id
    01 | 500 | 100900
    02 | 505 | 100900
    03 | 513 | 100900
    04 | 718 | 108000
    05 | 650 | 108000
    06 | 513 | 108000
    07 | 500 | 108000
    08 | 800 | 115000
    09 | 650 | 115000
    I need to select all the fields but only one record at a resource_id, leave with this result for example
    id | id_terr | resource_id
    01 | 500 | 100900
    04 | 718 | 108000
    08 | 800 | 115000
    Can anyone help me select this?
    Could it?
    Thanks
    Cristian
    Edited by: Munhoz on 25/09/2009 08:46

    with t as (
               select '01' id,500 id_terr,100900 resource_id from dual union all
               select '02',505,100900 from dual union all
               select '03',513,100900 from dual union all
               select '04',718,108000 from dual union all
               select '05',650,108000 from dual union all
               select '06',513,108000 from dual union all
               select '07',500,108000 from dual union all
               select '08',800,115000 from dual union all
               select '09',650,115000 from dual
    select  min(id) id,
            min(id_terr) keep (dense_rank first order by id) id_terr,
            resource_id
      from  t
      group by resource_id
      order by resource_id
    ID    ID_TERR RESOURCE_ID
    01        500      100900
    04        718      108000
    08        800      115000
    SQL>  SY.
    Edited by: Solomon Yakobson on Sep 24, 2009 6:28 PM

  • Doubt in SELECT query (11.2.0.2.0)

    I have 3 tables
    1. ADBO.SECMASTER_DTL_EXT_HST_TBL
    2. BDBO.SECMASTER_DETAIL_EXT_HIST
    3. ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
    ADBO.SECMASTER_DTL_EXT_HST_TBL and BDO.SECMASTER_DETAIL_EXT_HIST have exactly the same table structure.
    Now, I need to find out the records from table BDO.SECMASTER_DETAIL_EXT_HIST with the max effective_date
    which do not match to the effective_date in ADBO.SECMASTER_DTL_EXT_HST_TBL. In the results table I need to report the diff effective dates from the 2 tables if they do not match.
    Also, SRC_INTFC_INST has to be 140 in both 1 and 2 tables. Further security_alias of table 1 has to match with spoke_sec of table 3
    and security_alias of table 2 has to match with hub_sec of table 3.
    For the data I have , I am getting 2 rows whereas I am expecting only 1 row. Can anyone suggest why this is so??
       SELECT
             B.SECURITY_ALIAS,
              TO_CHAR (C.SPOKE_PAID),
              A.SECURITY_ALIAS,
              TO_CHAR (C.HUB_PAID),
              'SECMASTER_DETAIL_EXT_HIST',
              'EFFECTIVE_DATE',
              NVL ( (CAST (B.EFFECTIVE_DATE AS VARCHAR2 (100))),
                   'No Records Found'),
              NVL ( (CAST (A.EFFECTIVE_DATE AS VARCHAR2 (100))),
                   'No Records Found')
         FROM ADBO.SECMASTER_DTL_EXT_HST_TBL  A,
              (SELECT SECURITY_ALIAS, EFFECTIVE_DATE, SRC_INTFC_INST
                 FROM [email protected]) B,
              ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL C
        WHERE     A.SRC_INTFC_INST = 140
              AND B.SRC_INTFC_INST = 140
              AND A.SECURITY_ALIAS = C.spoke_sec
              AND b.security_alias = C.HUB_SEC
              AND TO_CHAR (a.effective_date,'DD-MON-YYYY')
               <> TO_CHAR((SELECT MAX (h.effective_date)
                        FROM [email protected] H                    
                         where h.security_alias = b.security_alias
                             AND h.src_intfc_inst = b.src_intfc_inst), 'DD-MON-YYYY')
            and a.security_alias='6313';
    Insert into ADBO.SECMASTER_DTL_EXT_HST_TBL
       (SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
    Values
       (6313, 140, TO_DATE('05/15/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into BDBO.SECMASTER_DETAIL_EXT_HIST
       (SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
    Values
       (327667, 140, TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into BDBO.SECMASTER_DETAIL_EXT_HIST
       (SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
    Values
       (327667, 140, TO_DATE('05/15/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
       (SPOKE_PAID, SPOKE_SEC, LAST_HELD_DATE, PREV_HELD_DATE, HUB_PAID, HUB_SEC)
    Values
       ('L3083                                                                                        ', 6313, TO_DATE('07/18/2013 22:15:46', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('07/15/2013 22:15:30', 'MM/DD/YYYY HH24:MI:SS'), 'L3083                                                                                        ',
        327667);
    CREATE TABLE ADBO.SECMASTER_DTL_EXT_HST_TBL
      SECURITY_ALIAS                  NUMBER        NOT NULL,
      SRC_INTFC_INST                  NUMBER        NOT NULL,
      EFFECTIVE_DATE                  DATE          NOT NULL
    CREATE TABLE BDBO.SECMASTER_DETAIL_EXT_HIST
      SECURITY_ALIAS                  NUMBER,
      SRC_INTFC_INST                  NUMBER,
      EFFECTIVE_DATE                  DATE
    CREATE TABLE ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
      SPOKE_PAID      VARCHAR2(100 BYTE),
      SPOKE_SEC       NUMBER,
      LAST_HELD_DATE  DATE,
      PREV_HELD_DATE  DATE,
      HUB_PAID        VARCHAR2(100 BYTE),
      HUB_SEC         NUMBER

    Hi,
    one suggestion. Don't include schema in the table.
    I have created your tables in my db with the following names:
    a_secmaster_dtl_ext_hst_tbl
    b_secmaster_detail_ext_hist
    spoke_to_hub_sec_mtch_tbl
    You query may be solved in this way maybe, according to what I have understood in the previous post.
    with table_a as
       select a.security_alias
            , c.spoke_paid
            , c.hub_paid
            , a.effective_date
         from a_secmaster_dtl_ext_hst_tbl  a
              join spoke_to_hub_sec_mtch_tbl c
                 on (a.security_alias=c.spoke_sec)
        where a.src_intfc_inst = 140
          and a.effective_date = (select max(a2.effective_date)
                                    from a_secmaster_dtl_ext_hst_tbl a2
                                   where a.security_alias=a2.security_alias
                                     and a.src_intfc_inst=a2.src_intfc_inst)
    , table_b as
       select b.security_alias
            , c.spoke_paid
            , c.hub_paid
            , b.effective_date
         from b_secmaster_detail_ext_hist  b
              join spoke_to_hub_sec_mtch_tbl c
                 on (b.security_alias=c.hub_sec)
        where b.src_intfc_inst = 140
          and b.effective_date = (select max(b2.effective_date)
                                    from b_secmaster_detail_ext_hist b2
                                   where b.security_alias=b2.security_alias
                                     and b.src_intfc_inst=b2.src_intfc_inst)
    select b.security_alias
         , a.spoke_paid
         , a.security_alias
         , b.hub_paid
         , 'SECMASTER_DETAIL_EXT_HIST' txt1
         , 'EFFECTIVE_DATE'            txt2
         , nvl(to_char(b.effective_date,'dd-mon-yyyy'), 'No Records Found') b_eff_date
         , nvl(to_char(a.effective_date,'dd-mon-yyyy'), 'No Records Found') a_eff_date   
      from table_a a full outer join table_b b on(a.spoke_paid=b.hub_paid)
    where a.effective_date!=b.effective_date;
    I have used full outer join to join the table to cover the case where records are present in table a and not in table b and the opposite.
    Regards.
    Alberto

Maybe you are looking for