How to use case and decode to extract the data

Hello PL/SQL Gurus,
I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production version
I have a table in following format -
drop table TT2;
create table TT2(College, Class,gender,status,fees) as select
'IITB','MBA','M','P',255600 from dual union all select
'IITK','MTech','M','P',300000 from dual union all select
'IITD','MBA','F','P',450000 from dual union all select
'IITKH','MBA','F','P',350000 from dual union all select
'IITC','MTech','F','P',420000 from dual union all select
'IITB','MTech','M','P',185000 from dual union all select
'IITC','MTech','M','P',235000 from dual union all select
'IITD','MBA','F','F',175000 from dual union all select
'IITM','MBA','M','F',257000 from dual union all select     
'IITKH','MTech','F','P',335000 from dual union all select
'IITD','MBA','F','P',540335 from dual union all select
'IITC','MBA','F','F',125089 from dual union all select
'IITD','MTech','M','P',290756 from dual union all select
'IITM','MBA','M','P',200000 from dual union all select     
'IITKH','MBA','F','F',534990 from dual union all select
'IITD','MBA','F','P',221000 from dual ;some of the extraction conditions are as following -
CASE CONDITION
College in 'IITB' and status='P'- 'WestRegion Passed'
College in 'IITC' and status='P'- 'SouthRegion Passed'
College in 'IITD' and 'IITK' and status='P' and Gender='F' - 'NothRegion Female Passed'
College not in 'IITK' and status='F' - 'Ex Kanpur Failed'
Expected output -
Region Statnding     Fees
WestRegion Passed     440460
SouthRegion Passed     655000
NothRegion Female Passed     1386335
Ex Kanpur Failed     1092079SQL Used
I am using the following query which only make sure of case but this is not how i want the output , if i try to use the case within decode then how to work on this -
SELECT (CASE WHEN College in ('IITB') and status='P' then sum(fees) else 0 end) WP,
(case when College in ('IITC') and status='P' then sum(fees) else 0 end) SP,
(case when College in ('IITD','IITK') and gender='F' and status='P' then sum(fees) else 0 end) NFP,
(case when College in ('IITK') and status='F' then sum(fees) else 0 end) ExKF
FROM
TT2
GROUP BY College, Class,gender,status

user555994 wrote:
Thank you so much jeneesh i am really thankful to you ...vov.
one more query in case if any of the selection don't have the output data , then values will be displayed like -One way..
with t as
--"Add all your descriptions
(select 'WestRegion Passed' region_standing from dual union all
select 'SouthRegion Passed' region_standing from dual union all
select 'NothRegion Female Passed' region_standing from dual union all
select 'Ex Kanpur Failed' region_standing from dual)
select region_standing,sum(fees) fees
        from (
        (SELECT CASE WHEN College in ('IITB') and status='P'
                            then 'WestRegion Passed'
                    when College in ('IITC') and status='P'
                            then 'SouthRegion Passed'  
                    when College in ('IITD','IITK') and gender='F' and status='P'
                            then 'NothRegion Female Passed'
                    when College in ('IITK') and status='F'
                            then 'Ex Kanpur Failed'
                    else 'Others' end region_standing,
                    sum(fees) fees
        FROM TT2
        GROUP BY  CASE WHEN College in ('IITB') and status='P'
                            then 'WestRegion Passed'
                    when College in ('IITC') and status='P'
                            then 'SouthRegion Passed'  
                    when College in ('IITD','IITK') and gender='F' and status='P'
                            then 'NothRegion Female Passed'
                    when College in ('IITK') and status='F'
                            then 'Ex Kanpur Failed'
                    else 'Others' end
        union all
        select region_standing,0
        from t
group by   region_standing;
REGION_STANDING              FEES
Others                     2567835
NothRegion Female Passed   1211335
WestRegion Passed           440600
Ex Kanpur Failed                 0
SouthRegion Passed          655000
{code}
Edited by: jeneesh on Nov 5, 2012 5:07 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to use CASE or DECODE in this?

    Hi , I have a query like this
    AND ...smthng
    AND --smtg
    AND age BETWEEN ....For the last AND clause for age column, I have the values passed from IN param of this SP in form of strings
    '0-30', '31-60', '61-90', and '91+'. The IN param is of course VARCHAR2.
    What I want to do in this AND clause
    e.g. for age range '0-30', the AND clause should be
    AND age BETWEEN ( if this range is '0-30' then ) 0 AND 30 ( if range is '31-60') then BETWEEN 31 AND 60.. and so on...
    However this BETWEEN will work till 61-90 range but for 91+ , there is no upper bound so it should be
    AND age>91
    Now , i am not sure how to achieve this both BETWEEN and '>' clauses in the same AND statement.
    DECODE will not work and am not sure how to use the CASE in this situation as even that can not solve this issue.
    Dont want to make the last AND clause dynamic
    Please suggest me how to do this.
    Thanks,
    Aashish
    Edited by: Aashish S. on Oct 21, 2011 6:01 PM

    A third alternative would be to choose a suitably large value as a high end for the 91+ group and use something like:
    age between to_number(CASE WHEN instr(:param, '+') = 0
                                  THEN substr(:param, 1, instr(:param, '-') -1)
                                  ELSE substr(:param, 1, instr(:param, '+') -1) end) and
                to_number(CASE WHEN instr(:param, '+') = 0
                               THEN substr(:param, instr(:param, '-') +1)
                               ELSE '9999' END)John

  • How to use interface and abstract class in the real time sennario ?

    how to validate password and reenter password fields in the struts through the xml files?

    Here is a modified dealForm.jsp that merges the 2 steps - both symbol submission and Yahoo convert is done by it. Play with it and add your DB code to it:
    <html>
    <head><title>IPIB Database Selection</title></head>
    <body bgcolor="#DFDFFF">
    <H1><CENTER>IPIB Database Selection</CENTER></H1>
    <font size=4>
    <%@ page language="java" %>
    <%@ page import="java.net.*,java.io.*,java.util.*" %>
    <%
    String symbol = request.getParameter("symbol");
    if (symbol != null) {
    String urlString = "http://finance.yahoo.com/download/javasoft.beans?SYMBOLS=" + symbol + "&format=ab";
    try {
    URL url = new URL(urlString);
    URLConnection con = url.openConnection();
    InputStream is = con.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line = br.readLine();
    StringTokenizer tokenizer = new StringTokenizer(line,",");
    String name = tokenizer.nextToken();
    name = name.substring(1, name.length()-2);
    String price = tokenizer.nextToken();
    price = price.substring(1, price.length()-2);
    %>
    <p>
    Original line from yahoo <%= line %>
    </p> <p>
    Name: <%= name %>
    </p> <p>
    Price: <%= price %>
    </p> <p>
    Pub DB processing code from dealLoad.jsp here
    </p>
    <%
    } catch (IOException exception) {
    System.err.println("IOException: " + exception);
    } else { %>
    <form action="dealForm.jsp"method="GET">
    <p>Enter Symbol: <input size="20" name="symbol">
    <inputtype="submit" value="Submit">
    </p></form>
    <% } %>
    </font>
    </body>
    </html>

  • [SOLVED] How to use timidity++ and other programs at the same time?

    I have installed timidity following arch wiki instructions - I have soundfont, and I start it in /etc/rc.conf
    It works properly with tuxguitar (and tuxguitar-alsa) or kmid, but I cannot play MIDI and - for example - oggs in amarok at the same time.
    I suspect that the problem is that timidity doesn't use dmix alsa plugin I have made in my ~/.asoundrc.
    The question is: how to tell timidity to use my dmix plugin?
    Last edited by senjin (2007-11-19 19:53:50)

    but they don't define "default" there, but "!default"...
    anyway, I have already both "default" and "!default" defined exactly the same way:
    pcm.!default
    type plug
    slave.pcm "dmixer"
    pcm.default
    type plug
    slave.pcm "dmixer"
    pcm.dmixer
    type dmix
    ipc_key 1024
    slave
    pcm "hw:0,0"
    format "S32_LE"
    channels 2
    period_time 0
    period_size 1024
    buffer_size 4096
    rate 44100
    bindings
    0 0
    1 1
    ctl.dmixer
    type hw
    card 0
    pcm.w_y_h
    type hw
    card 0
    device 0
    pcm.what_you_hear
    type plug
    ttable.0.10 1 # digital mix left
    ttable.1.11 1 # digital mix right
    slave.pcm w_y_h
    pcm.skype
    type asym
    playback.pcm "dmixer"
    capture.pcm "skype_input"
    pcm.skype_input
    type dsnoop
    ipc_key 2048
    slave
    pcm "hw:0,0"
    period_time 0
    buffer_time 0
    period_size 1024
    buffer_size 8192
    rate 44100
    and it doesn't work!
    Last edited by senjin (2007-11-18 17:49:21)

  • Win 8 - How to use StereoMix and Headphones Mic at the same time?

    I am using Windows 8 64 bit and believe I may have an IDT driver problem.
    I need to enable StereoMix and my Headphones Mic at the same time. I know this was previously possible with windows xp and windows 7.
    What happens is If I enable either Headphones Mic (Logitech headphones with Mic) or StereoMix the other one becomes " current;ly unavailable"  I cannot get them both to work together. I can get StereoMix and the Internal Mic to work together ( both enabled at the same time) but the sound quality is bad because the internal mic picks up noises from the PC. I need to have both my headphones mic and stereo mix enabled at the same time.
    The driver I'm using is the one provided by HP with the laptop. It is called sp59620.exe
    Would another IDT driver solve the problem? Can you think of another reason this is not working?
    Here are my specs.
    System Manufacturer/Model Number HP Pavillion G7-2251dx
    OS Windows 8 64 bit
    CPU AMD A-8 4500M
    Memory 8 Gigabytes DDR3 sdram
    Graphics Card Discrete ATI Radeon HD 7640G with 2 Gigs
    Sound Card IDT Audio
    Monitor(s) Displays 17.3
    Screen Resolution 1600x900
    If you cannot help, where else should I look? i have tried Windows and Microsoft forums and no one can give me an answer.
    Thank you.

    I have tried the instructions in that video and I cant get passed the very bad feedback i get when telling my recording device to Listen.  His secone instruction from his notes here
    ["Right Click the Realtech HD audio device and set as default if its not already.
    (note you may want to turn off any powered speakers you may have to prevent feedback.)
    -Select the Recording Tab at the top of the window.
    -Select the Stereo Mix device and set it to default if its not already.
    -Right click and select Properties.
    -Select the Listen Tab at the top of the window.
    -Change the drop-down box to the entry for USB headset and check the Listen to this device checkbox.
    -click ok to dismiss the window.
    -Right click on the USB headset microphone device and select properties.
    -Select the Listen Tab at the top of the window.
    -Change the drop-down box to the entry for the Realtech HD Audio device and check the Listen to this device checkbox.
    -click ok to dismiss the window.
    So, essentially, the game audio will play through the Realtec, your mic is also set to play to the Realtec. both audio streams are now part of Stereo Mix. Stereo Mix is being listened to by your headset allowing you to hear the game and your voice.]
    ~~~~~~~~~~~~~~~~~
    Don't know about turning off any powered speakers.. the only speakers I have besides the headphones are the internal laptop speakers.  I get the same feedback if i have the headphones plugged in or not.

  • HT4623 how to use itunes and download IOS for the phone

    Hi
    Recentle i am having problem using whats app application, it says my IOS system does not support....how do i use the I-tunes to down load this into my phone.  Thanks

    Basically Yes...
    See this long Discussion...
    https://discussions.apple.com/message/20723017#20723017

  • How to use a variable multiple times in the data flow

    DECLARE
    @StartTime datetime,
    @EndTime datetime
    SET @StartTime = (SELECT MAX(AvailDateTime) FROM dbo.Fact)
    SET @EndTime = (SELECT MAX(AvailDateTime) FROM dbo.Product);
    --DATEADD(day, 1, @StartTime);
    --PRINT @StartTime
    --PRINT @EndTime;
    WITH
    dates AS (
    SELECT DATEADD(Minute,5,@StartTime) AS [date]
    WHERE DATEADD(Minute,5,@StartTime) <= @EndTime
    UNION ALL
    SELECT DATEADD(minute, 5 ,t.date) AS [date]
    FROM dates t
    WHERE DATEADD(minute, 5, t.date) <= @EndTime
    I have the above sql, in this I'm using the 2 variables and calling @Starttime Variable couple of time. How should I build the SSIS package based on this query? how can I call the same variable in different place? how will SSIS take it?
    Thanks

    Since you have the variables set in code you just can place this code into the SQL code section of say an OLEDB source
    like there
    or

  • How to use a km service to show the data of collaboration rooms.

    I follow the method in documents:
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID);
    and cast Exception come out,  means can not transfer to IRooms
    And I alse wonder why PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID)'s return type is IService, but IRooms is not extends from IService ,how can casting succesussful......

    I follow the method in documents:
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    IRooms roomsAPI = (IRooms) PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID);
    and cast Exception come out,  means can not transfer to IRooms
    And I alse wonder why PortalRuntime.getRuntimeResources().getService(IRooms.PORTAL_SERVICE_ID)'s return type is IService, but IRooms is not extends from IService ,how can casting succesussful......

  • How to use case when function to calculate time ?

    Dear All,
    May i know how to use case when function to calculate the time ?
    for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.  
    CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
    THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
    THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
    ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
    ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOUR

    Do not use computations in a declarative language.  This is SQL and not COBOL.
    Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton. 
    CREATE TABLE Timeslots
    (slot_start_time TIME(1) NOT NULL PRIMARY KEY,
     slot_end_time TIME(1) NOT NULL,
     CHECK (start_time < end_time));
    INSERT INTO Timeslots  --15 min intervals 
    VALUES ('00:00:00.0', '00:14:59.9'),
    ('00:15:00.0', '00:29:59.9'),
    ('00:30:00.0', '00:44:59.9'),
    ('00:45:00.0', '01:00:59.9'), 
    ('23:45:00.0', '23:59:59.9'); 
    Here is the basic query for rounding down to a time slot. 
    SELECT CAST (@in_timestamp AS DATE), T.start_time
      FROM Timeslots AS T
     WHERE CAST (@in_timestamp AS TIME)
           BETWEEN T.slot_start_time 
               AND T.slot_end_time;
    --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

  • Case and Decode query

    Hi,
    I am running below statement.
    create table test_abc
    (cnt number,
    outcome varchar2(20));
    insert into test_abc values(1,'EXISTINGDOMFUELCUST');
    insert into test_abc values(1,'Answer Phone');
    insert into test_abc values(1,'Answer Phone');
    insert into test_abc values(1,'Answer Phone');
    insert into test_abc values(1,'Answer Phone');
    insert into test_abc values(1,'Answer Phone');
    commit;
    Now I used case and decode
    select count(*),ot from (
    select (case when outcome ='EXISTINGDOMFUELCUST' then 'Existing Domestic Fuel Customer'
    when outcome='Answer Phone' then 'Answer Phone'
    when outcome='Answer Phone' then 'Answer Machine' end) ot
    from test_abc)
    group by ot;
    select count(*),decode(outcome,'EXISTINGDOMFUELCUST','Existing Domestic Fuel Customer','Answer Phone',
    'Answer Phone','Answer Phone','Answer Machine')
    from test_abc
    group by decode(outcome,'EXISTINGDOMFUELCUST','Existing Domestic Fuel Customer','Answer Phone',
    'Answer Phone','Answer Phone','Answer Machine')
    and getting same output
    cnt ot
    5 Answer Phone
    1 Existing Domestic Fuel Customer
    but I want output should be
    cnt ot
    5 Answer Phone
    5 Answer Machine
    1 Existing Domestic Fuel Customer
    please suggest

    Indra Budiantho wrote:
    /* Formatted on 8/28/2012 3:10:28 PM (QP5 v5.139.911.3011) */
    SELECT CASE
    WHEN outcome = 'EXISTINGDOMFUELCUST'
    THEN
    'Existing Domestic Fuel Customer'
    WHEN outcome = 'Answer Phone'
    THEN
    'Answer Phone'
    END
    outcome,
    COUNT (*)
    FROM test_abc
    GROUP BY outcome
    union
    SELECT CASE
    WHEN outcome = 'EXISTINGDOMFUELCUST'
    THEN
    'Existing Domestic Fuel Customer'
    WHEN outcome = 'Answer Phone'
    THEN
    'Answer Machine'
    END
    outcome,
    COUNT (*)
    FROM test_abc
    where outcome = 'Answer Phone'
    GROUP BY outcomeo/p
    Answer Machine     5
    Answer Phone     5
    Existing Domestic Fuel Customer     1This can be simplified..
    Also, UNION will unnecessarily do a distinct operation.
    SELECT CASE
                WHEN outcome = 'EXISTINGDOMFUELCUST'
                THEN
                   'Existing Domestic Fuel Customer'
                WHEN outcome = 'Answer Phone'
                THEN
                   'Answer Phone'
             END
                outcome,
             COUNT (*)
        FROM test_abc
    GROUP BY outcome
    union all
    SELECT 'Answer Machine'
                outcome,
             COUNT (*)
        FROM test_abc
        where outcome = 'Answer Phone'
    GROUP BY outcome

  • Regarding case and decode.

    Hi !
    I need to return all the employess, and indicate with "YES" or "NO" wherther they receive a commission.
    I am trying to get this by using CASE and DECODE but result is comming different.
    USING DECODE:
    SELECT ename,
    sal,
    DECODE(comm,NULL,'NO',
    'YES') COMM
    FROM emp;
    USING CASE:
    SELECT ename,
    sal,
    CASE comm
    WHEN NULL THEN 'NO'
    ELSE 'YES'
    END
    FROM emp;
    DECODE is returning actual data(comm is NO where comm is null and comm is YES where comm is not null). Where as CASE is retunring YES for all employees commission even comm is null..
    I am not able to understand where I was wrong.
    Can any one help me out?
    Thanks
    Rajesh

    Hi Rajesh,
    I tried to solve your query this way, check if it serves the purpose
    /***Using Decode***/
    SELECT EMPLOYEE_ID, DECODE(NVL(COMMISSION_PCT, 0), 0, 'NO', 'YES')
    FROM EMPLOYEES
    /****Using Case***/
    SELECT EMPLOYEE_ID, CASE NVL(COMMISSION_PCT, 0)
    WHEN 0 THEN 'NO'
    ELSE 'YES'
    END CASE
    FROM EMPLOYEES
    /

  • How to use XVID MEPG4 DECODER in labview

    May i ask how to use Xvid MEPG4 Decoder to compress the AVI file. For this decoder have been installed in my computer but the VI(IMAQ AVI2 Get Codec Names)can not list this code name. So may i ask how can i use this decoder in the labview. For this decoder is relatively has good quality and also small size. Or what kind of other solution can be provieded for the relative small size of AVI file.
    Thanks
    Daniel

    I believe this was answered already in a different thread:  http://forums.ni.com/t5/LabVIEW/LabView-to-grab-and-save-video-to-mpeg/m-p/643864
    www.movimed.com - Custom Imaging Solutions

  • Can't extract the data from sourse system

    hi,everyone
       i have a question about extracting the data from sourse system.i created a general datasourse.in the r3 system,i used t-code:rsa3 to extract the data successful. but ,when i replicate the datasourse to the bw system,i can't extract the data to the psa. in the process of the extracting,accur a error like below:
    Errors while sending packages from OLTP to BI
    Diagnosis
    No IDocs could be sent to BI using RFC.
    System Response
    There are IDocs in the source system ALE outbox that did not arrive in the ALE inbox of BI.
    Further analysis:
    Check the TRFC log.
    You can access this log using the wizard or the menu path "Environment -> Transact. RFC -> In source system".
    Error handling:
    If the TRFC is incorrect, check whether the source system is fully connected to BI. In particular, check the
    authorizations of the background user in the source system.
    who can tell me why?
    thx
    zhang

    Hi zhang,
    Please check the below points.
    1. Perform the connection and authorization test in SM59 for the RFC connecion.
    2. Make sure the RFC user extracting the data is having sufficient authorization and correct profile as per note 150315.
    3. make sure there are sufficient number of Dialog process in BW in SM50.
    4. check T code SM58 in source system for any more errors.
    5. check the connection between the systems.
    Check
    Note 561880 - Requests hang because IDocs are not processed.
    Note 535172 - IDoc: Dup. IDocs in tRFC inbound processing w/ runtime error
    Note 555229 - IDocs hang in status 64 for tRFC with immediate processing
    Hope this helps.
    Regards,
    Suman.T

  • How to use CrossReference and DVM in ODI &how to populate data into Xref

    Can any one tell how to use Domain Value Maps and Cross Referencing in ODI?
    DVM or Domain Value Map are created and used in ESB console of SOA suite.
    My actual requirement is as follows:
    The below steps describe loading data from ERP Application 1 to ERP Application 2.
    1. The Source Application ERP APP1, populates the interface table using their native technology.
    2. A job scheduler invokes the Source side ODI Package.
    3. ODI then extracts the data from Source Interface table and populates the Target Interface table.
    4. After populating the Target interface table the ODI populates the X-ref table with App 1 ID and generated common ID.
    5. The ODI either deletes or updates the rows that were processed from the Source interface table.
    6. On the Target Application ERP APP2, the native application extracts data from target interface table and populates target database there by generating ERP Application 2 ID.
    7. A job scheduler on the Target application invokes the ODI package to populate the Application 2 ID onto the Xref table matching on the Common ID.
    I just want to know :
    1. How to populate data into the Xref table from Source datastore
    2. And if data is successfully laoded from target datastore to actual base table of target then how to populate the target id into the cross reference table.

    can anyone suggest me some answer, then it would be of great help?

  • How to use case function in where clause

    Hi,
    Suppose a table DEMO has columns
    DEMO TABLE
    user_id
    user_name
    location
    In this table i have 15 users. but out of 15 users i want to use only 5 users for passing as user_name.
    then how to achieve the result
    1. when i pass the particular 5 user_name in where clause then i should get all the user_name and for other 10 users it will show only the passing user_name.
    how to use case function

    Do you mean this ?
    SQL> var name varchar2(10)
    SQL> exec :name := 'ALLEN'
    PL/SQL procedure successfully completed.
    SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
      2  else :name end = ename;
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> exec :name := 'SMITH'
    PL/SQL procedure successfully completed.
    SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
      2  else :name end = ename;
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> exec :name := 'BLAKE'
    PL/SQL procedure successfully completed.
    SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
      2  else :name end = ename;
    ENAME
    BLAKERgds.

Maybe you are looking for

  • Assigning User to a Group.

    Hi All, We have installed EP 7.0. We need to add the user "xxx" to the group "SAP_HR_LSO_DEVELOPMANAGER". We searched for the user "xxx" and click on modify button to edit the Assigned groups. But the Add button is disabled for the Admin. How to enab

  • How to get a bootable vhd for a Linux on Hyper-V with two disks ?

    Hi folks, I am running a custom linux on my Hyper-V in Windows Server 2008 R2. I initially configured one disk(4GB) and then I added one more hard disk of higher capacity (8GB). Now I got two vhd files with different sizes. If I want to create a new

  • Copying fields from one screen to another

    Hi All, I want to move data from one field of a program to another field of a different program.  I mean, I have a date field (this field i will fill with the current date or any other date value) in my program.  This field is a parameter on my scree

  • Dynamic Tabstrip and Alv's

    Hi All, My requirement is like that dynamically i have to create tabstrip and in that each tab has Alv table to disply the data. Regards, Rajesh.

  • IFolder 3.4 client on Mac OSX Toger

    Hi I am having a problem with the 3. client on Mac, the server is the 3.5 running on SLES9. I am able to connect and sync ok from Linux and Windows machines. When I try on my mac machine I am able to log in ok, when I try to set up an ifolder I get t