Needs help for the query

Hi All,
I had atable containing 2 columns like NO and Grade.
ID Grade DEPTID
1 A 10
2 E 20
3 D 20
4 C 30
5 H 10
6 K 10
7 B 30
8 L 30
9 R 20
i need output as
DEPTID Employees and grades in the DEPT
10 1 A , 5 H , 6 K
20 2 E , 3 D , 9 R
30 4 C , 7 B , 8 L
Please anyone give me query for this.
thanks in advance.
rampa

STRAGG for string aggregation. One of the most frequent ask question over here.
Here a forum search for you.
Of course, the options depend of version you are on.
Nicolas.

Similar Messages

  • Need help for the query columns to rows

    Hi everyone,
    I have two tables TABLE1 and TABLE2; TABLE1 is Master table,TABLE2 is child table.
    The key for TABLE1 is C1 column
    The key for TABLE2 is C1,C_MONTH Columns
    The sample data is as follows
    TABLE1
    ======
    C1 C2
    1 A
    2 B
    3 C
    4 D
    TABLE2
    ======
    C1 C_MONTH C3
    1 JAN AAA
    1 FEB BBB
    1 MAR CCC
    1 APR DDD
    2 JAN ZZZ
    2 FEB YYY
    2 MAR XXX
    2 APR UUU
    I want to display the data as follows
    1 A JAN AAA FEB BBB MAR CCC APR DDD
    2 B JAN ZZZ FEB YYY MAR XXX APR UUU
    Can any one help me how to write this query?
    Thanks in advance

    [email protected] wrote:
    Thanks for the update
    but I want the out put as column values rather than one column as follows
    C1 C2 J_MONTH J_VALUE F_MONTH F_VALUE M_MONTH M_VALUE A_MONTH A_VALUE
    1 A JAN AAA FEB BBB MAR CCC APR DDD
    2 B JAN ZZZ FEB YYY MAR XXX APR UUUThis is a standard pivot.
    In 10g or below you can do something like...
    SQL> ed
    Wrote file afiedt.buf
      1  with table1 as (
      2                  select 1 c1, 'A' c2 from dual union all
      3                  select 2, 'B' from dual union all
      4                  select 3, 'C' from dual union all
      5                  select 4, 'D' from dual
      6                 ),
      7       table2 as (
      8                  select 1 c1, 'JAN' C_MONTH,'AAA' C3 from dual union all
      9                  select 1,'FEB','BBB' C3 from dual union all
    10                  select 1,'MAR','CCC' C3 from dual union all
    11                  select 1,'APR','DDD' C3 from dual union all
    12                  select 2,'JAN','ZZZ' C3 from dual union all
    13                  select 2,'FEB','YYY' C3 from dual union all
    14                  select 2,'MAR','XXX' C3 from dual union all
    15                  select 2,'APR','UUU' C3 from dual
    16                 )
    17  -- end of test data
    18  select table1.c1, table1.c2
    19        ,max(decode(c_month, 'JAN', c_month)) as jan_month
    20        ,max(decode(c_month, 'JAN', c3)) as jan_value
    21        ,max(decode(c_month, 'FEB', c_month)) as feb_month
    22        ,max(decode(c_month, 'FEB', c3)) as feb_value
    23        ,max(decode(c_month, 'MAR', c_month)) as mar_month
    24        ,max(decode(c_month, 'MAR', c3)) as mar_value
    25        ,max(decode(c_month, 'APR', c_month)) as apr_month
    26        ,max(decode(c_month, 'APR', c3)) as apr_value
    27  from table1 join table2 on (table1.c1 = table2.c1)
    28* group by table1.c1, table1.c2
    SQL> /
            C1 C JAN JAN FEB FEB MAR MAR APR APR
             1 A JAN AAA FEB BBB MAR CCC APR DDD
             2 B JAN ZZZ FEB YYY MAR XXX APR UUU
    SQL>From 11g upwards you can use the new PIVOT keyword.

  • Need help for the $200 promo rebate for trade-in of I Phone 4

    Need help for the $200 promo rebate for trade-in of I Phone 4.  Unable to preregister when I ordered the new 6  in September.  Now can not contact VZW recycle program regarding.

    When I ordered my phone on Sept. 13th in a Verizon store, I had to ask the salesman how I went about getting the $200 rebate. He said shipping materials would come with the new phones. When I received the confirmation e-mail of my order, it contained a link for the rebate. Fortunately I clicked on the link, filled out the form online, and received the packing materials to send my phone in shortly after. My phones came in on Oct. 14th and I sent 3 of them back. So far I have received a gift card for $200 for 2 of the phones; the other is showing not received. I don't know what your situation is, but I think the promotion ended Oct. 15th. If I had listened to the salesman I think I would be out of luck as well. I hope I am wrong for your sake.

  • I Need Help for the popup message every time I go to safari: "Warning! Old version of Adobe Flash Player detected. Please download new version."???

    I Need Help for the popup message every time I go to safari: "Warning! Old version of Adobe Flash Player detected. Please download new version."???

    If you are talking about Safari on the iPad, there is no version of Adobe Flash for iOS and there never has been. Clear Safari, close the app and reset the iPad.
    Go to Settings>Safari>Clear History and Website Data
    In order to close apps, you have to drag the app up from the multitasking display. Double tap the home button and you will see apps lined up going left to right across the screen. Swipe to get to the app that you want to close and then swipe "up" on the app preview thumbnail to close it.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    If you are talking about Safari on your Mac, you are in the wrong forum. But I would still clear the cache, quit Safari and restart the Mac.

  • Please Help for the Query

    Please Help for the Query
    Hi frds please help me for the below query.What I want to do is to pull out the data from below table :-
    date ticker indicator
    03/13/2008 3IINFOTECH -8
    03/18/2008 3IINFOTECH -4
    03/25/2008 3IINFOTECH -5
    03/27/2008 3IINFOTECH -3
    as such :-
    date ticker indicator
    03/13/2008 3IINFOTECH -8
    03/25/2008 3IINFOTECH -5
    03/27/2008 3IINFOTECH -3
    Here I want to find the Trend i.e either asc or desc order from the lowest indicator.
    In the above sample data -8, -4, -5, -3 out of which I want the asc order data -8, -5, -3 and exclude -4 data.Because the asc order -8, -5, -3 will not follow.
    So I want the data
    date ticker indicator
    03/13/2008 3IINFOTECH -8
    03/25/2008 3IINFOTECH -5
    03/27/2008 3IINFOTECH -3

    SQL> CREATE TABLE BORRAME(FECHA DATE, INDICA VARCHAR2(100));
    Tabla creada.
    SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/13/2008','MM/DD/YYYY'), '3IINFOTECH -8');
    1 fila creada.
    SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/18/2008','MM/DD/YYYY'), '3IINFOTECH -4');
    1 fila creada.
    SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/25/2008','MM/DD/YYYY'), '3IINFOTECH -5');
    1 fila creada.
    SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/27/2008','MM/DD/YYYY'), '3IINFOTECH -3');
    1 fila creada.
    SQL> COMMIT;
    Validación terminada.
    SQL>
    SQL> SELECT FECHA, INDICA
      2  FROM BORRAME
      3  WHERE SUBSTR(INDICA,INSTR(INDICA,'-',1)+1,LENGTH(INDICA)) <> '4'
      4  ORDER BY SUBSTR(INDICA,INSTR(INDICA,'-',1)+1,LENGTH(INDICA)) DESC;
    FECHA                                                                
    INDICA                                                               
    13/03/08                                                             
    3IINFOTECH -8                                                        
    25/03/08                                                             
    3IINFOTECH -5                                                        
    27/03/08                                                             
    3IINFOTECH -3                                                        
                    

  • Help for the query

    hello,
    I have a question again. The tables for the query are "Patient" and "Station".
    Station-Table:
    s_id, station
    Patient-Table:
    p_id, name, s_id, gender
    I want to know how many Patient are Male and Female for each Station. That means that the output should be:
    Station Male Female
    S1 12 10
    S2 6 4

    I supposed the values in gender are 'M' for Male and 'F' for Female
    select s.station, sum(decode(p.gender, 'M', 1, 0)) Male , sum(decode(p.gender, 'F', 1, 0)) Female
    from station s, patient p
    where s.s_id=p.s_id
    group by s.station;

  • Need help for the sql statement !!!!!

    hi all,
    i need a sql statement for a query, how can i get the result from the rownum between 100 and 150?
    plz help

    use a scrollable statement:
    PreparedStatement stat = Connection.prepareStement("select * from blah", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stat.executeQuery();
    rs.absolute(100);
    while (rs.next()) {
    String something = rs.get(1);
    Look into the JDK API reference for ResultSet to get an expalantion of scrollable statements.

  • Need solution for the query

    hi All,
    I have 3 tables 1)PREVILEGES (groupname, previleges(values y or n only))
    2)GROUPS (groupid, groupname)
    3) USERS (uname, groupname).
    Here each user belongs to one group, each user hav a default previlege means example if user is consutant then he can access only consultant group. Means default previlege will be used. For default previleges, there is no record in Previleges table.
    The Problem is that, I need to reterive the groupname from users which de doesn't belong as well as his previleges from previleges, If there is no values in previleges in the table it should return n. or value what is therey.
    the different groups are
    SALES,CONSULTANT,VENDER,RECRUTER,ADMIN

    [url http://forums.oracle.com/forums/thread.jspa?threadID=491856&tstart=0]duplicate thread

  • Need help for the installation of one key theater and the improper working of touchpad

    hi can anybody tell me how can i install one key theater in g560 laptop running on win 7 32 bit OS as me trying to install it but it doesnt work.
    How to solve the touchpad issue in g560 as sometimes the touchpad stops funtioning or not sensing the finger movement.

    Hi and Welcome to the Community!
    I'm not sure, from your description, exactly what you are looking for. "Username" and "E-mail"? Are you perhaps looking for the ability to enter a "reply-to" email address that is different from the actual email address of the account you are sending from? If so, that feature is indeed not presently available in BB10. Among other features, it may be one that many hope are added to the BB10 platform with future OS releases. But, for now, it is what it is.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Need help for the frontpanel of audigy and live soundcard !

    hi.
    ich habe eine frage.
    ich habe eine audigy 2 zs soundkarte ohne dieses
    frontpanel ,also es ist keine platinum und m?chte das frontpanel (I/O dri've)
    seperat erwerben.
    kann ich es an meiner soundkarte anschliessen oder geht das nur bei einer platinum ?
    und
    muss das unbedingt das frontpanel einer audigy 2 zs sein oder geht
    auch das von li've soundkarte ,da gibt es auch frontpanel ?
    mir geht es haupts?chlich um die optischen lichtleiterkabel,die ich zum anschluss
    vom kabel deutschland decoder zu meiner soundkarte ben?tige.
    w?re nett wenn mir einer das beantworten kann.
    mfg
    death

    Hi and Welcome to the Community!
    I'm not sure, from your description, exactly what you are looking for. "Username" and "E-mail"? Are you perhaps looking for the ability to enter a "reply-to" email address that is different from the actual email address of the account you are sending from? If so, that feature is indeed not presently available in BB10. Among other features, it may be one that many hope are added to the BB10 platform with future OS releases. But, for now, it is what it is.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Need help for the security setting

    We are preparing the demo environment with ADF Security turn on with Http Basic Authentication.
    Everything works fine but for a command that is send to one of our proxy servlet (context path /BIProxy), we got a pop up dialog that asks you to login to weblogic container.
    Anyone have any suggestion regarding what extra security configuration that I need to config to access to context path/servlet that is not default Faces servlet.
    The following is what we have in jazn-data.xml for region:
    <permission>
    <class>oracle.adf.share.security.authorization.RegionPermission</class>
    <name>testsecurity.pageDefs.untitled1PageDef</name>
    <actions>view</actions>
    </permission>

    Hi, we find more informaiton.
    We got two 401 errors which causes the login popup.
    o. For the 1st 401 error (expected), the http header is set to: WWW-Authenticate: Basic realm="jazn.com" so we enter the correct user credential, the dialog goes away.
    o. For the 2nd 401 error, the http header is set to: WWW-Authenticate: Basic realm="WebLogic Server" so we get "Authentication Required" dialog ask for WLS login.
    For the 2nd 401 error, we are pointing to /Sales-BaseSalesSalesHomePageUi-context-root/BIProxy?cid=BIPresentationServer&RedirectURL=res/b_mozilla/common/obips.ImportMeFirst.js from Referer URL: /Sales-BaseSalesSalesHomePageUi-context-root/faces/zbsSalesHomePage?_adf.ctrl-state=x5a1n5x2d_11
    So my quesiton is that do we need to add some security setting in jazn-data.xml or someother files to specify security setting for /BIProxy?
    Thanks

  • Hello . I need help for the CPU of changing

    My computer is a Compaq 6715b AMD Turion 64 X2 Mobile Technology TL-56th I'm going to change the processor in the AMD Turion X2 Ultra Dual-Core Mobile ZM-86th and add and DDR2 ram 800mhz.Ar me everything to work.Thanks for the advice

    Hi:
    Below is the link to the quickspecs for the HP 6715b.
    http://h18000.www1.hp.com/products/quickspecs/12686_ca/12686_ca.PDF
    The supported processors are listed on page 3.
    The processor you wish to install will not work in your notebook.

  • Need help for the following select query-- illegal character

    select product_group_id from product_group where description like '%%'
    I am not able to identify this character.
    When I try to type this character at
    SQL prompt, it does not accepts it.
    This character is in the description field and I have to replace it with NULL..
    Any suggestions..
    Thanks in advance
    null

    I'm not sure about the character you are talking about. But if you find this character in the ASCII character set, you can do all the operation against it with the help of CHR() function.

  • Need help for the web based project

    I am using netbeans 5.5 and Sql server for db.What is the full form for DAO and how is it going to help me in my project.U also talk about uml want ot know about it.
    and how is it coming to help me.Its a very wast topic i serached.what will be helpful to me of the UML.
    What should i start first --- jsp or db design.
    What should i use for web based project --- only use jsp(presentation)+dao or jsp+servlet+dao.What would be best ?
    provide some nice link based on dynamic fetching of values from the database and showing it at runtime.
    Message was edited by:
    java@mani

    As stated in http://forum.java.sun.com/thread.jspa?threadID=5167752 start reading the Java EE tutorial to get insights in the material.
    what will be helpful to me of the UML.UML generally visualizes the core functionality. See http://www.google.com/search?q=uml+tutorial for some tuts.
    What should i start first --- jsp or db design.Start with both and end with the best balance between both.
    What should i use for web based project --- only use
    jsp(presentation)+dao or jsp+servlet+dao.Depends on the business needs. Generally 3-tier webapplications are the best: web, business and data.
    provide some nice link based on dynamic fetching of values from the
    database and showing it at runtime.Check some SQL and JDBC tutorials how to fetch and process the data:
    http://www.google.com/search?q=sql+tutorial
    http://www.google.com/search?q=jdbc+tutorial
    How to process it in the business and web layer is stated in the Java EE tutorial I've linked in your former topic.
    For applying the patterns, check the http://java.sun.com/blueprints/corej2eepatterns/

  • Need help for a query

    Dear all,
    I have data in a table with 3 columns.
    Tabke name---test & columns are ....
    Proeductioncode varchar2(5);
    revisionno varchar2(3);
    dateadopted char(8);
    SELECT PRODUCTIONCODE,
    REVISIONNO,
    dateadopted
    FROM test
    where
    productioncode ='CI50E';
    output should be
    productioncode revisionno dateadopted
         CI50E     004     20110125     
         CI50E     001     20101104     
         CI50E     003     20110320     
         CI50E     002     20101214     
    My requirement is
    I wanna display records which are dateadopted is > sysdate and
    one record which is less than sysdate, which is the max(<sysdate)..
    from the data above, the output should be
    CI50E     003     20110320     
    CI50E     004     20110125     
    Please help me get this output. we need to write it in a select query.

    Sorry I don't have a database available to test - missed to join by productioncode :( grouping by revisionno caused more than one row being returned :(
    No need to send data. I added a data providing subquery. Will take shot when I get to the database, but I might not be able to post from the office
    with
    /* generating test data */
    test as
    (select 'CI50E' productioncode,'004' revisionno,'20110125' dateadopted from dual union all /* 003 if increasing by date */
    select 'CI50E','001','20101104' from dual union all
    select 'CI50E','003','20110320' from dual union all                                        /* 004 if increasing by date */
    select 'CI50E','002','20101214' from dual union all
    select 'XI50Y','001','20110220' from dual union all
    select 'XI50Y','002','20110220' from dual union all
    select 'XI50Y','003','20110304' from dual 
    /* end of test data generation */
    SELECT productioncode,revisionno,dateadopted
      FROM (select productioncode,revisionno,dateadopted
              from test a
             where (dateadopted > to_char(sysdate,'yyyymmdd'))
                or dateadopted = (select max(dateadopted)
                                    from test
                                   where productioncode = a.productioncode
                                     and dateadopted < to_char(sysdate,'yyyymmdd')
    ORDER BY PRODUCTIONCODERegards
    Etbin
    Edited by: Etbin on 20.2.2011 21:58
    did some alignment
    Edited by: Etbin on 21.2.2011 7:39
    missing right parenthesis added, group by clause removed since there is just a single product
    Edited by: Etbin on 21.2.2011 7:52
    some more data edit

Maybe you are looking for

  • HP 7610 won't scan to usb

    I have had this printer for several months.  I absolutely love it. However, recently it has been giving me problems when I try to scan to my USB. My USB is 64GB (Core Micro) brand. I scanned using this memory stick before. Not sure why this error mes

  • A scrolling problem for MFF 12

    I have found that on certain websites, the vertical scroll bar is missing altogether. This seems to carry over to other websites. And I only downloaded Firefox 12 yesterday!

  • Problems installing Photoshop Elements 4.0/5.0??

    Hi all, I recently attempted to download Photoshop Elements 4.0/5.0 from CS2 found here:  http://www.adobe.com/downloads/cs2_downloads/index.html . I am on a Macbook Pro (2011), and running Mountain Lion. I am receiving an error message (shown below)

  • Problems with Timecode Reader?

    I can seem to get The Timecode Reader Filter to see that my sequence starts at hour 2 and not hour 1. I can't seem to change the numbers either. Anyone know a trick for this?

  • Open FCExpress projects with FCP

    Hi Mac friends, I once had FCExpress. Not any more. I´ve all FCExpress projects and all the media stored on an external FW hard drive. Can I open this projects now with FCP and save them as new FCP Projects in order to use and preserve this works? If