How to use multiple aggregate functions in single query

hi to all
The output will be giving first_name,last_name,max(salary),min(salary) and the output will be department wise.From employees table in single query
output will be:
first_name|last_name|max(salary)|min(salary)

SELECT first_name||' '||last_name as ename,
       MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
       MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
FROM   emp
ORDER BY deptno, sal;Edited by: Ramio on Jan 10, 2012 10:43 PM

Similar Messages

  • How to use multiple tape drive for single filesystem on single client.

    Hello All.
    I want to backup single filesystem with multiple tape drive.
    Incase of Symantec veritas netbackup "NEW_STREAM" for multi-stream backup.
    Backup client has a  single backup filesystem like /data1  directory with 4 LTO6 drives.
    /data1 directory doesn't have a sub-direcotry, just present a files.
    If /data1 directory has a sub-directory like /data1/aaa, /data1/bbb, /data1/ccc , Is it possible to use multiple drives?
    Please anybody answer the questions.
    Thanks advanced.

    See how to use multiple tape drive from single client when I want to backup single filesystem?

  • How to insert multiple records in a single query

    Dear all,
    Can you please tell
    how to insert multiple records in a single query ??

    INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
    INSERT INTO table_name
    (column_1, column_2)
    SELECT 'value_A', 'value_B' FROM DUAL
    UNION ALL
    SELECT 'value_C', 'value_D' FROM DUAL
    ;Edited by: Benton on Nov 9, 2010 1:59 PM

  • How to use multiple hierarchies for a single char in single query

    Hi,
    Is there any way that we can use multiple hierarchies for a single char in single query. I tried and it just allows me to select one hierarchy even if I use hierarchy variable.
    I have a requirement where user wants to see information related to a cost center with different cost center groups in different hierarchies (every year has different cost center group hierarchies).
    Suppose I want to see information related to a cost center from year 2001-2004.in these four year cost center may have been associated to different groups depending upon that year hierarchy. How can I do that?
    Thanks
    Jona

    Nope. Now way to do this.
    There is always just one hierarchy assigned to a characteristic. And even if the hierarchy was time dependent, it only reads it for one key date and not according to transaction data.
    Regards,
    Beat

  • How to use multiple tape drive from single client when I want to backup single filesystem?

    Hello All.
    I want to backup 1 filesystem using 4 tape drives for reducing backup time.
    In case of symantec veritas netbackup, they can user "NEW_STREAM" for multi-streaming backup.
    Please anybody let me know that how to do use multiple tape drive for single client.
    1. Backup Source server : Linux (1 client)
    2. Backup Soucre :      /data1  (500GB)
        -> Current directory structure doesn't have sub directory under /data1, just files present under /data1
    If direcotry struceture has a sub-direcotry like( /data1/aaa, /data1/bbb ), Is it availble to use multiple tape drives?
    3. Tape Drive with OSB : LTO6 * 4 drives
    Thank you.

    You would have to create a different dataset for each sub-folder. If you only have files at the top level folder then even the NEW_STREAM option couldn't be used to split the job.
    Organise it into folders and then create datasets in a client folder such as :
    /usr/local/oracle/backup/admin/config/dataset/Linux/data1_aaa
    /usr/local/oracle/backup/admin/config/dataset/Linux/data1_bbb
    Then in the schedule you just specify the Linux folder. In each dataset you list the hostname and the folder name, such as :
    include host Linux
    include path /data1/aaa
    Now it will create a new job for each dataset and therefore each folder.
    Thanks
    Rich

  • How to use multiple xmlforest() function within xmlagg() function

    I need to create following XML structure by reading multiple tables from DB .
    The tables are relational and joined by keys.
    <Invoice>
    <CaseOrdrId>0000022359</CaseOrdrId>
    <Id>100065117</Id>
    <Prescription>
    <CaseOrdrItmId>0000005684</CaseOrdrItmId>
    <RxId>1104900686</RxId>
    <Prescriber>
         <CasePartyIdDEA>0000000000</CasePartyIdDEA>
         <CasePartyIdNPI>0000000000</CasePartyIdNPI>
         <CasePartyIdSLic>0000000000</CasePartyIdSLic>
         </Prescriber>
         <PatInfo>
              <CasePartyId>0000000000</CasePartyId>
              </PatInfo>
    </Prescription>
    </Invoice>
    <Invoice>
    <Invoice>
    <Invoice>
    <Invoice>
    <Invoice> tag can repeat 5times , So,I am using xmlagg().
    To create the tree structure within <Invoice> I am using multiple xmlforest().
    But getting error : SQL Error: ORA-06553: PLS-306: wrong number or types of arguments in call to 'SYS_IXMLAGG' . code added today marked in yellow.
    Any help on this would be really helpful.

    Hi , I could fix the previous issue with xmlagg().
    My query is as follows :
    select
    xmlelement( "Response", xmlforest( b.StatusCode as "StatusCode", b.StatusMessage as "StatusMessage",
    b.ServiceAction as "ServiceAction",
    select
    xmlforest( a.id as "Id", a.ExternalId as "ExternalId", a.Source as "Source", a.UserID as "UserID", xmlforest(b.id as
    "Id")"Note", xmlforest(
    select
    Xmlforest(P.Case_Party_Id As "CasePartyId",Xmlelement("CaseGeoAddrId",S.Address_Id )as "Address"
    from
    v44139.party p,
    v44139.patient_address s
    where
    p.case_party_id = s.case_party_id
    and p.party_id_type_cde = 'MBR'
    AND s.individual_agn_id = 0
    ) as "Membership")"Group",
    select
    xmlagg(xmlelement("Invoice",xmlelement( "CaseOrdrId",d.case_order_id),
    xmlelement("Id" ,d.invoice_nbr) ,xmlelement("Prescription",
    xmlforest(e.case_order_item_id as "CaseOrdrItmId", e.rx_nbr as "RxId"),
    xmlelement("Prescriber",
    xmlforest(169629 as "CasePartyIdDEA", 169630 as "CasePartyIdNPI",169631
    as "CasePartyIdSLic")),xmlelement("PatInfo",xmlforest(e.case_party_id as "CasePartyId") )) ) )
    --AS ID
    from
    v44139.patient_order d ,
    v44139.order_rx e
    where
    d.case_id = a.id
    and d.case_order_id = e.case_order_id
    as "Invoice"
    from
    select
    '142' as id,
    'CMRT' as source,
    'V44042' as userid,
    'EMG-7788' as externalid ,
    361 as case_party_id
    from
    dual
    a
    "Case") ) as "XML_QUERY"
    from
    select
    200 as statuscode,
    'SUCCESS' as statusmessage,
    '0000000000' as id,
    'Update' serviceaction
    from
    dual
    b;
    ===============================================================================================
    The result is as follows :
    <Response><StatusCode>200</StatusCode><StatusMessage>SUCCESS</StatusMessage><ServiceAction>Update</ServiceAction><Case><Id>142</Id><ExternalId>EMG-7788</ExternalId><Source>CMRT</Source><UserID>V44042</UserID><Note><Id>0000000000</Id></Note><Group><Membership><CasePartyId>382</CasePartyId><Address><CaseGeoAddrId>144</CaseGeoAddrId></Address></Membership></Group_*><Invoice><Invoice><*_CaseOrdrId>202</CaseOrdrId><Id>999999993                                         </Id><Prescription><CaseOrdrItmId>105</CaseOrdrItmId><RxId>1118800008</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382               </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>203</CaseOrdrId><Id>825478795                                         </Id><Prescription><CaseOrdrItmId>106</CaseOrdrItmId><RxId>1118800005</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382               </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>204</CaseOrdrId><Id>999999992                                         </Id><Prescription><CaseOrdrItmId>107</CaseOrdrItmId><RxId>1118800007</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382               </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>205</CaseOrdrId><Id>999999991                                         </Id><Prescription><CaseOrdrItmId>108</CaseOrdrItmId><RxId>1118800006</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382               </CasePartyId></PatInfo></Prescription></Invoice></Invoice></Case></Response>
    The ISSUE : <Invoice> tag repeating twice in 3 rd line . How to correct this ?

  • How to use SEM_RELATED & SEM_MATCH in a single query

    Hi,
    I am trying to combine RDF and RDBMS data using SEM_RELATED.
    Below sample is working fine but the requirement is i have to add few more conditions in SEM_MATCH
    Please suggest me how to combine sem_match and sem_related in a single query.
    Please provide me the example which use SEM_MATCH and SEM_RELATED in a single query.
    SELECT distinct dg_term_property.CONTEXT_NM FROM dg_term_property,dg_term
    WHERE SEM_RELATED ('<http://www.cs.com/mdm/data_glossary#Facilities>',
    '<http://www.w3.org/2000/01/rdf-schema#subClassOf>',
    '<http://www.cs.com/mdm/data_glossary#Reference_Data_Classes>',
    sem_models('GSR_PR_CURR'), sem_rulebases('owlprime')) = 1
    and DG_TERM.TERM_NM=DG_TERM_PROPERTY.TERM_NM;
    Let me know if you need any other details.
    Regards,
    Kavitha.

    Hi Kavitha,
    I am not sure what exactly you are trying to accomplish with this query but the use of the SEM_RELATED is incorrect. To fulfill your requirement most likely you may not even need to combine SEM_RELATED with SEM_MATCH. Actually those two are not built to be used together.
    Take a look at the SEM_RELATED documentation and see if you can use it to get the results you need. The example that you are providing is not using the SEM_RELATED correctly.
    Here is the documentation:
    http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/owl_concepts.htm#CHDJBGFI
    Go to:
    2.3 Using Semantic Operators to Query Relational Data
    Regards!
    Jorge
    Edited by: jbarba on Aug 20, 2012 10:20 AM
    Edited by: jbarba on Aug 20, 2012 10:21 AM

  • How to calculate multiple aggregation in a single query

    how to find firstname ,lastname for max and min salary from employees table group by department in a single query?
    Edited by: Gnanasekar on Jan 10, 2012 6:36 AM

    check this query
    select ENAME,SAL
    from EMP
    where SAL in(select max(SAL)
                       from EMP
                      group by DEPTNO)
    or SAL in(select min(SAL)
                 from EMP
                  group by DEPTNO)Hope this will help you..
    You should ask this question at sql/plsql forum
    If someone's response is helpful or correct, please mark it accordingly.

  • How to use multiple scripts on a single .fla file

    Hi, I'm making a tiny game and don't want to have thousands upon thousands of lines of code to deal with. I was curious if there was a way to use a different script for a different level in my game.

    Probably, though it is not clear what you mean.  You can have code divided and planted in as many different places as you please for the most part. But you will still have the same thousands upon thousands of lines to deal with.

  • How to use user defined function in select query using Toplink

    Hi Friends
    I am little bit of new in Toplink stuff... so please help me...
    I have to database functions 1. encrypt and 2. decrypt.
    I want to exceute the following sql query using toplink
    select port, database, user_name, decrypt(encrypt('String which is to be encrypt ','password'),'password') from CONFIGURATION
    can anyone tell me , how to write code in toplink which will give the about sql output.
    thanks .....

    The "Specifying a Custom SQL String in a DatabaseQuery" section in the TopLink Developer's Guide may help... http://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28218/qrybas.htm#BCFHDHBG

  • How to insert multiple records with a single query?

    Hi,
    I've to save a huge number of installments with their other information such as due on blah blah. Now, I want to add the all of these information at once with a single insert query.
    How can I do that?

    Hi
    What is your source data?
    If the source is external to the SQL Server (like a log file, Excel, CSV, JSON, XML, external application...) you can and should insert it all using Bulk Insert operation.
    Pls clarify what is your source data, and if you need more help using Bulk Insert.
    https://www.simple-talk.com/sql/learn-sql-server/bulk-inserts-via-tsql-in-sql-server/
    http://msdn.microsoft.com/en-us/library/ms188365.aspx
    [Personal Site] [Blog] [Facebook]

  • How to use Mulitple DAQs with a single triggered event on only one of the DAQs

    I have three PXI6115 and would like to tie all these to a single triggered event on one of the DAQs. I've scaned the examples and any assistance would be greatly appreciated....

    TCjr,
    Please refer to your other post:
    How to use Multiple DAQs with a single triggered event on only one of the DAQs

  • How to use multiple classes for each form

    Hi,
    I have created two forms using screen painter and now i want to use different classes for these two forms .
    I have declared the Sbo Connection in main class i.e. Set Application ,Connection Context() but while connecting to other classes
    for executing the code for that form SAP is not connected to that class.How to use multiple classes functionality i don't able to
    do that.Please provide some sample codes for that as it will be more helpful for me to understand.
    Thanks & Regards,
    Amit

    Hi Amit,
    In fact, its more advisable to use separate classes for every form that you use.  Have one common class, say, for eg., clsMain.cs which has all the connection and connectivity to other classes, wherein, the menu event and item event of this main class, will just be calling the menu / item event of other classes.
    The individual functionality of the child classes will be called from the item / menu event of the respective classes.
    Item event in clsMain.cs will be as below.
    private void oApplication_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
                SAPbouiCOM.Form oForm;
                BubbleEvent = true;
                try
                    if ((pVal.FormTypeEx == "My_Form1Type") && (pVal.EventType != SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD))
                        oForm = oApplication.Forms.GetForm("My_FormType", pVal.FormTypeCount);
                        NameSpace.Repots.ClsForm1.ClsForm1_ItemEvent(oApplication, oCompany, oForm, ref pVal, ref BubbleEvent);
                    if ((pVal.FormTypeEx == "My_Form2Type") && (pVal.EventType != SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD))
                        oForm = oApplication.Forms.GetForm("My_FormType", pVal.FormTypeCount);
                        NameSpace.Repots.ClsForm1.ClsForm2_ItemEvent(oApplication, oCompany, oForm, ref pVal, ref BubbleEvent);
    Now, in the individual classes, you can have their respective item events, which will be called from the main class, and the respective functionalities will occur.
    Hope this helps.
    Regards,
    Satish.

  • How To Use Multiple Currencies in single payroll ........

    Dear All
    Can you help me How To Use Multiple Currencies in single payroll?
    with regards
    User600722

    I am not a functional expert. but ML Note 150173.1 (which is quite old) states that this is not possible.
    Srini

  • How to use multiple table in single control file?

    Hi,
    How to use multiple table and data file in sigle control file? I have a four table and four csv file i mean data file for that. I am running concurrent program to load the data from csv file to custom table. based on my input data file name, it has to take automatically from one control file.
    Can anyone share with me how can i acheive this?
    Thanks

    Hi,
    Can't we acehive like below. I don't this exactly corrcect.
    OPTIONS (SKIP=1)
    LOAD DATA
    INFILE << file name 1 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         PARENT_ITEM               "TRIM(BOTH FROM :PARENT_ITEM)"
    LOAD DATA
    INFILE << file name 2 >>
    APPEND INTO TABLE XXCZ_VA_SAMPLE2
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
         ITEM_NUMBER               "TRIM(BOTH FROM :ITEM_NUMBER)"
    )Edited by: orasuriya on Sep 14, 2009 3:03 AM

Maybe you are looking for