How to Retrive Data using Case or any other method

Hi All
i am new to Oracle, i have three tables. 1 )*Person* contains following data
id,     Name,      DOB
98,     sss,     01/01/2009
99,     rrr,     01/01/2009
100,     rws,     01/01/2009
2) Reference Table Contains Following Data
Person_ID,     Ref_type,     Reference
98,     AAA,     jk98923
98,     BBB,     io9898
99,     AAA,     nb6666
100,     BBB,     g10090
now i need all pesons who got reference AAA only, i dont want to use any where clause. this because i have to incoporate this logic in Business Objects Report.
i need output as follows
Person_ID,     Name,      Reference
98,     sss,     jk98923
99,     rrr,     nb6666
100,     rws,     NULL
guys i know this is so simple for you, please come back to me on this. many thanks in advance
Edited by: user11078264 on 17-Apr-2009 05:46

How about something like this (note the WITH clause was used to generate sample data)?
SQL > WITH person AS
  2  (
  3  SELECT 98  AS ID, 'sss' AS NAME, TO_DATE('01/01/2009','MM/DD/YYYY') AS DOB FROM DUAL UNION ALL
  4  SELECT 99  AS ID, 'rrr' AS NAME, TO_DATE('01/01/2009','MM/DD/YYYY') AS DOB FROM DUAL UNION ALL
  5  SELECT 100         AS ID, 'rws' AS NAME, TO_DATE('01/01/2009','MM/DD/YYYY') AS DOB FROM DUAL
  6  ),
  7  reference AS
  8  (
  9     SELECT 98       AS PERSON_ID, 'AAA' AS REF_TYPE, 'jk98923' AS REFERENCE FROM DUAL UNION ALL
10     SELECT 98       AS PERSON_ID, 'BBB' AS REF_TYPE, 'io9898' AS REFERENCE FROM DUAL UNION ALL
11     SELECT 99       AS PERSON_ID, 'AAA' AS REF_TYPE, 'nb6666' AS REFERENCE FROM DUAL UNION ALL
12     SELECT 100      AS PERSON_ID, 'BBB' AS REF_TYPE, 'g10090' AS REFERENCE FROM DUAL
13  )
14  SELECT     PERSON_ID
15  ,  NAME
16  ,  MAX(DECODE(REF_TYPE,'AAA',REFERENCE,NULL)) Reference
17  FROM       person
18  JOIN       reference ON person.id = reference.person_id
19  GROUP BY PERSON_ID, NAME
20  ORDER BY PERSON_ID
21  /
PERSON_ID NAM REFEREN
        98 sss jk98923
        99 rrr nb6666
       100 rws

Similar Messages

  • How to validate date using case statement.

    I have date like 022212. I split month,date,year using STUFF Function. Now, i have to validate month in range 01-12 and date in range 01-31.  Can some one help me with the query.
    Thanks, Shyam Reddy.

    That is not  date; it is apparently a string (we have no DDL because you are so rude). Any competent SQL programmer will use DATE.   You want help with a query, but there is no query.  
    CAST ('20' + SUBSTRING (crap_string_date, 5,2)+'-' + SUBSTRING (crap_string_date, 1,2) + '-' +  SUBSTRING (crap_string_date, 3,2)  AS DATE) AS redddy_screwed_up_date 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to retrive data from SQL or any database.

    Hi Experts,
                      I am integrating FTP, DATABASE and SAP R/3 system. 
    1. FTP system stores xml files processed by customer requesting account info.
    2. Database system ( SQL/Oracle)  consists of Details about Customer accounts.
    3. Finally response ( Account info ) to be sent to SAP R/3 system (customer request and database response)
    Scenario:  Customer request regarding account info is stored as xml in FTP server. XI has to pick the xml file and retrieve the relevant data from Database (SQL / Oracle) and store the whole data in SAP R/3 System.
    Please let me know which BAPI I need to use for this scenario..and if you could explain the steps involved for this scenario that will really helps me.
    Thanks and Regards,
    Sunil

    I dont think there will be a separate bapi for this scenario.
    Use file adapter to pickup the file, call the JDBC adapter in synchronous mode (call a Stored Procedure) and then call an RFC or proxy to push the data in to R3.
    Refer and File to Jdbc and File to RFC scenarios. You might need to use BPM if you below SP14 on XI 3.0 I believe..!!
    VJ

  • How to Extract data using Query or any data fucntion in Excel.

    Dear Users,
     i want to ask one question about excel..............
    i have a parts list sheet, it contains part-number , price, name........ in columns. now my question is this that for example  part names are as under ,
    fix contactor
    moveable contactor
    half contactor
    contactor gm
    contactor skf
    as you saw in the names of parts contactor is the same in all the column. i want such a query that extract all the entries which contain contactor and make a new column or highlight them in the same column. my requirement is very similar to dos command when
    i want to see the list of all files which have exe extension ...dir *.exe.
    Best Regards
    Tahir Mehmood

    =IFERROR(IF(FIND( "contactor" ,LOWER(A1))>0,TRUE,FALSE), FALSE)
    This formula checks cell A1 and will flag TRUE if it matches the requirements of the specified text.  Have wrapped a lower function around the cell to mitigate for different upper or lower case mismatches.
    Alternativey you can use conditional formatting > "Use a formula to determine which cells to format" and use the following formula  =FIND("contactor", LOWER(A1)) >0.  Change the format to colour in the cell and copy the
    format down to all corresponding cells.  This will now highlight those that match the text value.
    Regards

  • How to retrive data from selected checkboxes with fieldnames

    hi experts,
    how to retrive data from selected checkboxes with fieldnames into another alv grid report.(here the fieldnames selected from  table names is dynamically).
    thankx in advance
    rani.k.

    Hi,
    Use user_command in the alv grid and then
    do the follwoing code
    FORM user_command1 USING lv_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Declaration of local Variables
      DATA : lv_ref1 TYPE REF TO cl_gui_alv_grid.
      DATA lv_cnt TYPE i.                                    "+INS SUHESH 12.07.2008
    Check function code
      CASE lv_ucomm.
        WHEN 'ONLI'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              e_grid = lv_ref1.
          CALL METHOD lv_ref1->check_changed_data.
    now loop ur final internal table where check = 'X'.
    now pass data to other internal table..Now the internal table will be having values that the user selcetd on the screen.
    Hope this helps.
    Regards,
    Nagaraj

  • How to retrive data from SAP Archive (from Cluster or Content Table)

    Hi,
    I am working on HR -ABAP where i have a scenario to retive employee photo and disaplay as output in smartforms.And these employee photo are stored in Cluster table SDOKCONT1 in SAP Archive Link (storage type - SAP System Database).
    Anybody can tell me the way how to retrive data ( employee Photo ) from this cluster and display its output in smartform dynamically.
    Regards,
    Sourabh Shrivastava

    Hello Sourabh,
    If I am not wrong, there are two parts two your query...
    a) Data or Content Retrieval
    b) Displaying Retrieved content
    Here is my feedback
    a) The Content can be Retrieved using the FM ARCHIV_GET_TABLE.
    Pass the Archive Object, SAP Object and the SAP Object ID and based on the Connection table entries (TOA*), the underlying Content Repository (T-code OAC0) is determined and a request for synchronous retrieval is made to the Content Server.
    b) Display of Retrieved content is normally done through dedicated viewers (Ex: Livelink Viewer) or front-end applications (Excel, Word) based on the Protocol (OAA3/OAA4) specified in the Content Reository Configuration. Hence, to my knowledge, you cannot display the content directly in the Smartform.
    With Regards
    Vijay Gajavalli

  • A relative synced my iphone with his laptop without me knowing. It had a passcode on the phone but the sync still worked. I have since found out he is quite IT knowledgeable and has been known to track other peoples phones.  How is this data useful to him

    A relative synced my iphone with his laptop without me knowing. It had a passcode on the phone but the sync still worked. I have since found out he is quite IT knowledgeable and has been known to track other peoples phones that he wants to know information about.  How is my data useful to him and can he restore this data on another iPhone and run it parallel to mine? I have had people send me messages which I have not received. These have been screen shot to me later including time and I have just not got them. I had 4 weeks worth of messages go missing from my phone..I know that he synced my phone because his work laptops I'd came up in my settings. Also if the above can be done can he change the settings on my actual phone and access my location without placing tracking software on my phone.  Can someone please help here as I can't restore a backup to my phone for obvious reasons and refuse to change my number because of this loser.

    Connect the device to the computer.
    In iTunes, select the content desired to sync.
    Sync.
    This is all described in the User's Guide, reading it may be a good place to start.

  • HOW to retrive data from SAP Tabel

    Hi Friends,
       1)Can you please explain how to retrive data from SAP table(example AFRU).
       2) we had requriment based on the qunatity , Product name and date we need to display KPI's .KPI is based no products manfactured per day with some conditions
    Regards
    Srikanth

    Hi Udayan,
        I want to retrive SAP Table data from xMII.can you please explain elabarately how to call "RFC_READ_TABLE" from xMII.
    please do the needful
    Thanks
    Srikanth

  • How to retrive data  from  database views or projection views

    how to retrive data  from  database views or projection views

    Hi chintam,
    1. Very simple
    2. Just like normal select statement.
    3. Select * from VIEWNAME.
    4. (Instead of the tablename, we just have to give the viewname)
    regards,
    amit m.

  • How to retrive data from this inernal table

    hi,
    could u please explain clearly how to retrive the records  from this structure
    data: begin of itab.
    include structure sflite.
    data:end of itab.
    how to retrive data from this structure could u plz give me a code with example.

    Hi,
    TYPES: BEGIN OF struc1,
                    val1 TYPE c,
                    val2 TYPE c,
                 END OF struc1,
             BEGIN OF struc2,
                   val type struc1,
                   val3 TYPE c,
                   val4 TYPE c,
                END OF struc2.
    DATA: l_f_str1 type struc1,
          l_f_str2 type struc2.
    START-OF-SELECTION.
      l_f_str2-val-val2 = 'a'.
      write : / l_f_str2-val-val2.
    END-OF-SELECTION.

  • How to copy data from one column to other column

    hi,
    can any one tell me how to copy data of  one column to other column for some specific data
    example
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120                   
    p002       2007                   90               100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    i want to copy data of p001 and p002 from prevplansales to current plansales
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120              120     
    p002       2007                   90               100              100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    is it possible to do?
    please suggest me.
    i will assign points

    Hi,
    I think the needed techniques are already described in the documentation, e.g. in
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    or
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    The main techiques used in the above example to bind the filter of the planning function to selected (marked) objects in the analysis item or to drop down boxes (or both). These techniques are used in the above examples.
    Regards,
    Gregor

  • Testing WebDynpro Adobe Interactive forms Using eCATT or any other testing

    Hi All,
    We are testing WebDynpro Adobe forms (Java). is there any methodology to test Interactive forms not normal webdynpro applications. Especially Interactive form with UI fields like dropdwons, datepickers dropdown values are from BAPI/RFC's  in these forms we will perfom actions like send data to backend and display PO created in onther view.
    once we repaly the test script all the drop down values are not updated this test scenario we tested with LR.
    Is there any procedure to test this scenario using eCATT or any other testing Tool.
    Rehards,
    Murali

    Hi Vara,
    You can develop Interactive forms using WD ABAP also.
    [E Learning- Interactive Forms using WD ABAP|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/media/uuid/c766e918-0b01-0010-99b1-c2b78cd059b3]
    WD Java is useful in case, when your ABAP system is less than ECC 6.0. Otherwise you can achieve same functionalities in WD ABAP also.
    Hope this will help you.
    Amit

  • You can only authorize this computer with an Adobe id that hasn't been previously used to authorize any other computer or mobile device

    When I try to download a library book on my Kobo reader, I keep getting this message. First it tells me to change the computer's authorization to be associated with an Adobe ID. When I click on authorize after logging in, the message keeps telling my "you can only authorize this computer with an Adobe ID that hasn't been previously used to authorize any other computer or mobile device. I have no idea what this means. Help!

    Sometimes ADE gets its registration/activation confused and in a semi-authorized state.
    Uninstalling and reinstalling does not help, and indeed installation can even trigger this state.
    Unfortunately, it often then gives misleading error messages about what is wrong.
    A common incorrect message informs you that the ID is already in use on another computer and cannot be reused.
    Another is  "E_AUTH_NOT_READY"
    This can often be resolved by completely removing any authorization using ctrl-shift-D to the Library screen on ADE (cmd-shift-D if on Mac).
    Restart ADE, and then reauthorize with your (old) Adobe ID.
    In extreme cases on the mac, the following extra step has helped some people.  Navigate to /Users//Library/Application Support/Adobe/Digital Editions and drag the activation.dat file to the trash. If you are using 10.7, see Access hidden user library files | Mac OS 10.7 Lion. http://forums.adobe.com/thread/1265248?tstart=0

  • HT203977 I can't find my back up data through (Woundershare) or any other software to download my back up data to my PC

    I can't find my back up data through (Woundershare) or any other software to download my back up data to my PC

    ALF316 wrote:
    Yes its my Time Machine disk that’s damaged. What can I do now? Format the disk and loose all my back-ups?
    You may be able to restore individual items, or even an entire backup, as long as you don't happen to hit the damaged area(s).  But yes, your only real option is to erase the disk and start over.  When you do that, you might want to take the time to have Disk Utility write zeros to the entire disk (see section (b) in the blue box of #1 in Using Disk Utility if you're not sure how to do that) -- if that fails, you know the disk itself is failing and must be replaced.  If it succeeds, the drive may be ok.
    And how can I prevent this in the future. I know at least I had to have a second back up disk but I never did that.
    You probably don't know yet what caused it.  If it's the disk failing, obviously you need a new one.  Other things that can cause disk corruption are power blips, being disconnected improperly, or your Mac crashing or losing power while the disk is connected, especially during a backup.
    For power problems, the best solution is a U.P.S. (battery backup) system.  A good surge protector will protect against power spikes, but not dips or sudden loss of power.
    I allready tried several times to change ownership with Get Info but I can’t. I don’t see a checkmark and the
    section isn’t clickable either. Any other suggestions?
    The screenshot is of your TM drive.  The message is about the drive you're trying to copy to, such as:

  • I have an ipad 2 an iphone 4 and run a windows pc i want to push all my current emails and folders if possible to both devices using icloud or any other option available

    i have an ipad 2 an iphone 4 and run a windows pc i want to push all my current emails and folders if possible to both devices using icloud or any other option available

    Will you be the person paying for apps on both accounts?
    Are you the only person that will use both of the iPads?
    Is there a chance students will be using the work iPad and if so, do you want personal data stored on it?
    If you're the only one using it I'd keep the same account just to have the flexibility of having access to everything on all devices. If your students will be using it or if the school is paying for the school apps I'd keep separate accounts. It all depends on how often you will use school apps from home, and home apps at school. Just some things to consider...

Maybe you are looking for

  • Default value for color_well

    Hello all, i want to write an export plugin but didn't know how to set the default value for the control color_well in the exportPresetFields. The entry { key = 'c_text_forecolor', default = LrColor(0,0,0)  } causes no error message but the control i

  • How to display a pop up window using a button redirect to a page ?

    Hi I have a button who redirect to a page of the application and this button passes a few items using the URL parameters (Optional URL Redirect). I would like to display the new URL page in a pop up window, with the items set properly Where do I put

  • How to use removeFromSuperView and dismissModelViewController same time ?

    I have a UIViewController *view1. By using [self presentModalViewController:view2 animated:YES]; I added UIViewController *view2 to view1. I have a UITableViewController *table1; I added table1 to view2 by using [self.view addSubview:navController.vi

  • Some web sites not working in FF but they are OK in Safari.

    A couple of times lately I have had web sites not work correctly with Firefox. I need to switch to Safari to complete the tasks I needed to do. My FF is running on Mountain Lion and is up to date. Thanks, MJT

  • CRM ORg Modle Replication

    Dear Friends, Can any1 give me clarrification please?? Do we have to make some settings to be able to replicate Org model?? I see some customising steps bleow but i don get why and when they have to be used.... Enhanced Back end Integration version o