Add Group by for the Query..

While executing the following query error has came
ORA-22818: subquery expressions not allowed here
22818. 00000 - "subquery expressions not allowed here"
*Cause:    An attempt was made to use a subquery expression where these
are not supported.
             SELECT TO_CHAR(nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno
                              )), 'YYYY') year1
             ,a.name cn1
             ,SUM(a.amt) amt1
         FROM dept a
             WHERE a.name = 'SCOTT'
             AND nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno)) >= TO_DATE('01' || '01/2011', 'dd/mm/yyyy')
           Group By TO_CHAR(nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno
                              )), 'YYYY')
                ,a.name
                        TO_CHAR(nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno
                              )), 'YYYY')
                ,a.name
            ORDER BY TO_CHAR(nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno
                              )), 'YYYY')
                ,a.name
                        TO_CHAR(nvl(a.date2, (SELECT MAX(aud.date1)
                              FROM emp aud
                              WHERE aud.deptno=a.deptno
                              )), 'YYYY')
                ,a.name;                    Anybody plz...
Edited by: BluShadow on 04-Jul-2011 12:00
added {noformat}{noformat} tags.  Please learn to do this yourself {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

hi,
dow you want this?
not tested
SELECT yearmax, deptname, SUM(amt1) summ
FROM
(SELECT a.name deptname, a.amt amt1, a.date2,
                         TO_CHAR(nvl(a.date2,(SELECT MAX(aud.date1)
                                FROM emp aud
                              WHERE aud.deptno=a.deptno)),'YYYY') yearmax
   FROM dept a)
WHERE deptname = 'SCOTT'
  AND yearmax >= TO_DATE('01' || '01/2011', 'dd/mm/yyyy')
Group By yearmax,deptname
            ORDER BY yearmax,deptname;

Similar Messages

  • Error in SQL Query The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query

    hi Experts,
    while running SQL Query i am getting an error as
    The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    T2.LineText
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,T2.LineText
    how to resolve the issue

    Dear Meghanath,
    Please use the following query, Hope your purpose will serve.
    select  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
    CAST(T2.LineText as nvarchar (MAX))[LineText]
    from OQUT T0  INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
    QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
    group by  T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
    ,CAST(T2.LineText as nvarchar (MAX))
    Regards,
    Amit

  • Save Query - An error occurred while creating connection strings for the query

    A workbook trying to edit and reload I get the following error "Save Query - An error occurred while creating connection strings for the query" No Power Pivot data model or anything.

    I am getting the same error when editing a Power Query in an Excel spreadsheet. It happens when I change a Group By step to do a Sum instead of Count Rows.

  • 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;

  • RPD - Cannot obtain number of columns for the query result :Working with MS SQL 2012 schema

    Hi All,
    I have created my warehouse in MS SQL 2012.
    For management purpose, I have created different schemas in SQL database
    In RPD, Physical layer, when i view data > I get error as
    [nQSError:16002] Cannot obtain number of columns for the query result.
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name 'tbl'..
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Statements could not be prepared..
    I have already browsed : OBIEE 11g Strange ODBC Driver Error with SQL Server : Total Business Intelligence ... did not help me
    please help!!!

    Hi All,
    After all R&D it is been found that Oracle business administrator( RPD) needs default dbo schema. It doesn't accept custom schema for pulling data.
    If anybody have other views please share.!!
    Thank you

  • To know the users and the variables for the query

    Hi,
    Say I have one query and which is executed 5 times in the day n i can see this in ST03N Expert mode. Now, suppose i want to see the users who executed the query and what are the selections they gave for the query to run, is there a place to see this?
    Appreciate your time
    Sriram

    Sriram,
    You can use BW Statistics to view technical information regarding users. SAP also delivers queries that give you usage by users, just install from business content. The statistics cubes extract data from various tables including:
    RSDDSTAT
    RSDDSTATAGGR
    etc..
    You can search more, names will start with "RSDDSTAT*"
    Hope it helps,
    Farhan

  • ALE/IDOC:The group data for the material CS94163AOOO is locked by ECPUSER

    Dear All,
    I have extended the idoc for MATMAS and getting -The group data for the material CS94163AOOO is locked by ECPUSER
    error on receving ( production ) server.I have written BDC in Z-function module to upload the data for extended segments after calling IDOC_INPUT_MATMAS01  function module.
    When the same scenario executed in development server the material is not getting locked and idoc is posted successfully.
    Please guide to resolve the error.
    Thanks,
    Sanjay Deshpande.
    Edited by: sanjay_123 on Nov 1, 2009 4:41 PM

    Hello,
    Can you pls try to use ENQUEUE_E_TABLE or FM specific to lock/unlock MARA table during Idoc creation.
    and put some WAIT statement before creation.
    CALL FUNCTION 'ENQUEUE_EMMARAS'
    EXPORTING
    MODE_MARA = 'S'
    MANDT = SY-MANDT
    MATNR = 'CS94163AOOO'
    X_MATNR = ' '
    _SCOPE = '2'
    *_WAIT = ' '
    _COLLECT = ' '
    EXCEPTIONS
    FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2
    OTHERS = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Then write code for creation of MARA
    Unlcok now like this
    CALL FUNCTION 'DEQUEUE_EMMARAS'
    EXPORTING
    MODE_MARA = 'S'
    MANDT = SY-MANDT
    MATNR = 'CS94163AOOO'
    X_MATNR = ' '
    _SCOPE = '3'
    _SYNCHRON = ' '
    _COLLECT = ' '
    ~Pramod
    Edited by: PKUPADHYAY on Nov 1, 2009 5:40 PM

  • [Consolidation-Locked] Please add RAW support for the Nikon D600 to Lightroom as soon as possible!

    My Fair Adobe,
    Please add RAW support for the Nikon D600 to Lightroom as soon as possible!
    ViewNX lets me get to the images, but come on!!! I know Lightroom, and you, ViewNX, are no Lightroom.
    Yes, I see everyone else ASKING for D600 support. I'm here to beg for it! Don't make me wait much longer!
    Message title was edited by: Brett N
    Message title was edited by: Brett N

    Rob, my reading of your site is that this plug-in copies settings from raw to jpeg, does it work the other way around as well?
    Rob Cole wrote:
    One of the great things about the new 0-based defaults and linear tone curve is:
    You can develop the jpegs now, in Lightroom, and then sync the settings to the raws later (e.g. using RawPlusJpeg), and provided you select a matching camera profile, they will look almost the same (white balance won't translate over, but everything else will, more or less). Beware lens corrections applied to the raws might alter the registration of precision local adjustments.
    Note: I recommend shooting with ADL off in order for this to work better, and consider turning sharpening off in camera as well, and noise reduction and everything else to whatever extent is possible.
    Rob

  • Enter commodity code/ Group code for the hierachy

    Hi Experts,
    I am trying to create New trading goods material by copying another similar material but here the issue is when I am trying to save the material mesage says Enter commidity code/ Group code for the hierarchy. This message is coming when every thing is finish and trying to save at the end of the transaction.
    I believe we need to maintain commodity codes in customizing for sales and distribution especially foreign trade.
    Any one can give me idea what is the configuration for this step by step.
    Appreciate your help
    Thanks
    Krishna

    Hello,
    Commodity code can be configured in SPRO->Sales and Distribution->Foreign Trade/Customs->Basis data for Foreign Trade->Define Commodity Codes / Import Code Numbers By Country.
    You maintain the same at country level.
    Thanks,
    Venu

  • Program name for the query generated using sq0102-03

    Hi Folks,
    How can we know the proggram  name for the query generated using sq01 and all?
    K.Kiran.

    Hi Kiran,
    U can get program name of nay transaction code by following this procedure
    after entering tcode it will direct u to the related screen then on the tool bar select system then go for status there u can find program name
    Rewards if helpfull
    Regards,
    Pavan

  • Is there an add on antenna for the iphone 4

    Is there an add on antenna for the iphone 4?  Having trouble with connection from my home.

    Pretty sure no iPhone ever had antenne connector

  • 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                                                        
                    

  • Hello I can't add fingerprint touched for the iPhone 5s i cant press add fingerprint what to do?.ios 8.0.2

    Hello I can't add fingerprint touched for the iPhone 5s i cant press add fingerprint what to do?.ios 8.0.2

    Touchid not touched

  • How to  Export/Import "report for the query" to another company

    Hello,
    I do this:
    1.create query in SQL analizer
    2.copy paste into SBO query generator and save
    3.create report for the query
    Then, How to Export/Import "report for the query" to another company ?
    Thanks for your HELP.

    Look for SAP Note number 600813
    That's the note Adele means, I guess.
    <b>Edit (@13:18)</b>
    The direct link:
    https://websmp101.sap-ag.de/~sapidb/012006153200000183292003E.ITF
    ---- Replace *SOURCE* with the source database name.
    ---- Replace *DEST* with the destination database name.
    insert into [*DEST*].[dbo].[RDOC]
    select [*SOURCE*].[dbo].[RDOC].*
    from
    [*SOURCE*].[dbo].[RDOC],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf]
    where [*DEST*].[dbo].[cinf].[lawsset]=[*SOURCE*].[dbo].[cinf].[lawsset]and [*DEST*].[dbo].[cinf].[version]=[*SOURCE*].[dbo].[cinf].[version] and [*SOURCE*].[dbo].[RDOC].[Doccode]NOT IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
    insert into [*DEST*].[dbo].[RITM]
    select [*SOURCE*].[dbo].[RITM].*
    from [*SOURCE*].[dbo].[RITM],[*DEST*].[dbo].[cinf],[*SOURCE*].[dbo].[cinf] where [*SOURCE*].[dbo].[RITM].[Doccode] NOT IN (select Doccode from [*DEST*].[dbo].[RITM])AND [*SOURCE*].[dbo].[RITM].[Doccode]IN (SELECT Doccode from [*DEST*].[dbo].[RDOC])
    Hope it helps...
    Grtz, Rowdy

  • [svn:osmf:] 10440: Add parser support for the Video tag.

    Revision: 10440
    Author:   [email protected]
    Date:     2009-09-20 15:03:56 -0700 (Sun, 20 Sep 2009)
    Log Message:
    Add parser support for the Video tag.  Add unit test for an empty document.
    Modified Paths:
        osmf/trunk/libs/VAST/.flexLibProperties
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTInlineAd.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/parser/VASTParser.as
        osmf/trunk/libs/VASTTest/org/openvideoplayer/vast/parser/TestVASTParser.as
    Added Paths:
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTMediaFile.as
        osmf/trunk/libs/VAST/org/openvideoplayer/vast/model/VASTVideo.as

    The video tag only supports a few formats and MKV (Matroska Multimedia Container) isn't one of them.<br />
    Your only option is to use the object (or embed) tag and use a player that can handle that format.<br />
    If might be better to switch to the WebM format.<br />
    * https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements

Maybe you are looking for