Case In The Group By cluses

I Need To Group By Case having sub query is it possible
select
segment3,
( case when segment3 like '210%' and segment4 in ( select child_m from apps.XXNBE_PAR_PROD) then (select parent_m from apps.XXNBE_PAR_PROD where segment4=child_m) else ' ' end ) AS PC,
sum(br_egp) IN_BR_EGP
from apps.XXNBE_FIN_R7 R7
group by
segment3
,( case when segment3 like '210%' and segment4 in ( select child_m from apps.XXNBE_PAR_PROD) then (select parent_m from apps.XXNBE_PAR_PROD where segment4=child_m) else ' ' end );
It's Returne The Error subquery expressions not allowed here

You cant use sub-queries in group by. Try this
select a.segment3,
       case when a.segment3 like '210%' and
                 b.child_m is not null
            then b.parent_m
    else ' '
       end as pc
  from app.XXNBE_FIN_R7 a
  left
  join apps.XXNBE_PAR_PROD b
    on a.segement4 = b.child_m
group
    by a.segment3,
       case when a.segment3 like '210%' and
                 b.child_m is not null
            then b.parent_m
    else ' '
       end

Similar Messages

  • Creating the New Update groups in case of the Credit Management

    Hi Can any one help out in the following requirement:
      Is it possible to Create a new update group in case of the Credit Management?SAP standard provides only three update groups viz., 000012, 000015 and 000018. We would like to have a customized group in order to meet the clients requirements.
              Also is it possible to update the open contracts value in the credit exposure?
       Thanks & Regards
       Soma

    HI
    You can define your own credit groups  according to your client's requirement.
    here is the path....
    IMG > SPRO>SALES AND DISTRIBUTION --> BASIC FUNCTIONS -->
    CREDIT MANAGEMNT / RISK MANAGEMENT --> CREDIT MANAGEMENT
    -->  DEFINE CREDIT GROUPS --> NEW ENTRIES AND CREATE YOUR OWN
    CREDIT GROUPS AS UR UR REQUIREMENTS.
    hope this will help u ...
    bye

  • Why is the GROUP BY clause not working in my Query?

    Dear All,
    Below is the Query for a Summary Debtors Aged Analysis.
    The GROUP BY clause does not seem to be working.
    The Query returns all the unpaid invoices, instead of a single total row for each Customer.
    If a Customer X has 10 unpaid invoices, 10 rows are displayed - one for each invoice.
    I was expecting only 1 row for Customer X, 1 for Customer Y, etc.
    This is what GROUP BY is supposed to do, but it is not doing its work.
    What has gone wrong?
    Thanks
    Leon Lai
    Here's my Query:
    declare @taxdt datetime
    set @taxdt
    /*select 1 from jdt1 t0 where t0.TaxDate*/ = [%1]
    SELECT
    CASE
                 WHEN T0.Account = 1220101 THEN 'Prim Cust'
                 WHEN T0.Account = 1220102 THEN 'Fgn Cust'
                 WHEN T0.Account = 1220103 THEN 'Local Cust'
                 WHEN T0.Account = 1220104 THEN 'Staff Loan' 
                 WHEN T0.Account = 1220105 THEN 'Dep with TP'
                 WHEN T0.Account = 1220106 THEN 'Adv to Cust'
                 WHEN T0.Account = 1220108 THEN 'Sund Drs'
                 ELSE 'Error ! ! !'
    END AS 'Control A/c',
    T1.CardCode AS 'BP Code',
    T2.Notes2 AS 'BP Name',
    SUM ((T0.Debit - T0.Credit)) AS 'Orig. Rs',       
    SUM ((T0.BalDueDeb - T0.BalDueCred)) AS 'Bal. Rs',     
    ((SELECT SUM(T0.BalDueDeb) - Sum(T0.BalDueCred)
        WHERE DateDiff(mm, T0.TaxDate, @taxdt) = 1))    
        AS '1 Mth Ago' 
    /* Similarly for other age brackets*/
    FROM JDT1 T0
    INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    LEFT OUTER JOIN OCPR T2 ON T1.CardCode = T2.Cardcode
    LEFT OUTER JOIN OJDT T3 ON T0.TransID = T3.TransID
    LEFT OUTER JOIN OINV  T4 ON T3.TransID = T4.TransID
    LEFT OUTER JOIN ORIN  T5 ON T3.TransID = T5.TransID
    WHERE
    T1.CardType = 'C'
    and (Balance) != 0
    and (T0.BalDueDeb - T0.BalDueCred) != 0
    GROUP BY T0.Account, T1.CardCode, T2.Notes2, T0.TaxDate

    Dear Neetu,
    Thanks for your reply.
    This Query is a modification of the Query you posted in SAP B1 SQL TIPS & TRICKS
    http://wiki.sdn.sap.com/wiki/display/B1/SAPB1SQLB-FNDebtorsAgingReportbydate
    So, maybe instead of referring to my Query, let's refer to yours. It may be easier for you to understand me.
    Once I understand the problem, I can adapt your query to suit my requirements
    So, let's start with a clean slate:
    The Query you have posted is for a DETAILED Debtors Aging Report.
    This lists all outstanding invoices, and ages them in the Age Brackets.
    What I want is a SUMMARY Debtors Aging Report.
    This will give the total amount owed by each Customer, and this amount is broken down in the Age Bracket Columns
    There will be a single row listed for each customer, something like this:
    Customer     Total Due     Current      1 Mth          2 Mth         3 Mth  etc
    Alfred       500,000       300,000       200,000
    Charles      800,000                     100,000       300,000       400,000
    How can you modify your query to make it become a Summary Report (1 line for each customer even if he has many invoices)?
    Thanks
    Leon Lai
    Here's your code
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > [%1]) AND T0.RefDate <= [%1] AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

  • I set up family sharing with a secondary ID and now can't add my primary ID to the group.

    I signed up for family sharing with a secondary Apple ID that I use for the iTunes store, and included my wife in the group. When I try to also include my primary Apple ID, I get an error message that says "You cannot send an invitation to your own account." The iOS Family Share page lists the secondary ID as the account to share purchases but also shows my primary ID at the top of the page, so apparently has my family group linked to that account as well. I do have some apps in my main account that I need to include in the family group, so I do I get Apple to allow me to include both IDs in that group?
    <Email Edited by Host>

    In my case the email I had for the family share account was my secondary ID, also listed on my primary account as a backup. I removed it as a backup, but family share still shows that primary ID listed under my name in the Family Share account, but the secondary as the account that will share purchases in Family Share. It still won't let me add the apps in the primary account into family share.

  • How to remove suppressed items in the group tree from the crystal report print preview screen

    I am removing items in report using group selection formula. Although the removed items are not available in the report, they are still available in the group navigation tree on the left pane. Is there a way to overcome this ?

    Hi All,
    How can i use the below group selection code in record selection.
    TotalQuantity := sum({ICIVAL.QUANTITY},{ICIVAL.ITEMNO});
    TotalCost := sum({ICIVAL.TRANSCOST},{ICIVAL.ITEMNO});
    iIncludeQty := TONUMBER({?INCLUDEQTY});
    iIncludeCost := TONUMBER({?INCLUDECOST});
    bIncludeQty := FALSE;
    bIncludeCost := FALSE;
    SELECT iIncludeQty
        CASE 0:
            bIncludeQty := TRUE
        CASE 1:
            If TotalQuantity > 0 THEN
                bIncludeQty := TRUE
        CASE 2:
            If TotalQuantity = 0 Then
                bIncludeQty := TRUE
        CASE 3:
            If TotalQuantity < 0 THEN
                bIncludeQty := TRUE
        CASE 4:
            If TotalQuantity <> 0 THEN
                bIncludeQty := TRUE
    SELECT iIncludeCost
        CASE 0:
            bIncludeCost := TRUE
        CASE 1:
            If TotalCost > 0 THEN
                bIncludeCost := TRUE
        CASE 2:
            If TotalCost = 0 Then
                bIncludeCost := TRUE
        CASE 3:
            If TotalCost < 0 THEN
                bIncludeCost := TRUE
        CASE 4:
            If TotalCost <> 0 THEN
                bIncludeCost := TRUE
    bIncludeQty AND bIncludeCost

  • Sum of a sum when using Top N in the Group Sort Expert

    Hi All,
    I have a small problem I can't quite seem to work out.
    I have a report where each line is for a particular Product, and is a summation of the Sales for that Product over several Locations. When you click on the line, it shows the breakdown of Sales over each Location.
    I use the Group Sort Expert to display the Top N results, where the 'N" is set in a formula to a parameter passed in to the report, so the user can select the top 5,10,50 etc. Products across all Locations.
    At the bottom of the report, I want to have a sum of a column of Sales $. I need that sum to only be a sum of the Top N records selected.
    Since each line is a summation of the all the products for the Locations, what I need is a sum of that sum for the Top N, but Crystal will not let you add the sum of a sum, so I'm not sure how to accomplish this.
    If I just do a sum of the underlying values I get a total for all the Products, regardless of the Top N.
    Hope that makes some sense !
    Many Thanks
    Paul

    Hi Sastry,
    I tried your suggestion, thanks, but I don't think it's the answer. For a start Crystal will not let me do that, it pops up a message box when I try to run the report "A running total cannot refer to a print time formula. Details: Record Number". I also added the record number field next to the lines in the report to see what the result would be, and I don't think it would work anyway.
    Here is an example using Units sold:
    Product Name--LocationUnits Sold--Record Number
    Product A -<All Stores>----8
    Store A--1--
    1
    Store B--3--
    2
    Store C--4--
    3
    Product B--<All Stores>--3      
    Store A--2--
    4
    Store B--1--
    5
    Product C--<All Stores>--
    1
    Store A--1--
    6
    Note that only the bold lines are shown in the report,. If you click on the bold line, then the breakdown of the stores is shown. For the above example, I am showing the Top 2 units across all stores (so Product C is not shown at all), but there are actually 5 records, so if I used a formula where RecordNumber <=N, where in this case N=2, I would get a total units sold of 1 + 3 (records 1 and 2) which is incorrect.
    I will have more of a think on this and see if I can find a solution, in the mean time, any other suggestions ? Is there some wya of checking if the line is visible maybe ?
    Thanks for your time !
    Paul

  • Error Message when logging on "The Group Policy Client service failed the logon. Access is denied"

    Since the move to Windows 7 we have started getting this error above when people login at random times and on random machines, at first we thought it was only a select few users, but now it seems to have occurred to about 20 different Staff members working
    at the school. Also of those 20 odd users it has happened to them on a few occasions.
    What we know
    We know this problem is only occurring to staff with Roaming Profiles, it seems like somehow the profile is not Synchronizing with the Servers File Share that houses the profiles, which causes the NTUSER.DAT file to become corrupt and go from being around
    2 – 3 MBs to 256KB (In all cases where a user has had this issue there NTUSER.DAT file has been 256KB)
    Current Resolution to the problem
    When a staff member contact us with this problem, we fortunately have Previous Versions working on the profiles folder on the server, so we are able to restore their NTUSER.DAT file from 1 to 2 days before it became corrupt, which then seems to allow them
    to log on fine
    What we have tried so far & suggested so far
    After some research on Google, we found the following thread on EduGeek
    http://www.edugeek.net/forums/windows-7/78733-windows-7-user-profile-failed-error-again.html#post700415
    Which suggested that the problem may lay within registry, so we implemented the Script that was posted on the website, however this has not seemed to make any difference
    In the early stages when only 5 – 10 staff seemed to be having the problem, we believed the issue could be with just certain AD accounts. It had not seemed to happen to any recently created AD accounts so we thought it could be a corrupt attribute on
    the user so we delete one of the staff AD accounts that had the problem and creating a brand new one, however within about 2 – 3 weeks that staff member had the issue occur again
    Leading on from point two, we also thought the problem could be with people using multiple computers, logging on in 2 places and not logging off properly, but unfortunately the staff member referred to in point 2 only uses the one computer in reception.
    Another potential cause that we figured might be the route of the problem, was it could be specific computers that are not communicating properly with the server, which could be causing this problem to occur, but we have no real way of testing this,
    as the staff generally log onto 3 – 4 different computers throughout the day and in different location
    We log a call with EE and they just pointed us to various websites that we had already checked and wasn’t much help.
    In Summary
    This error has now occurred with about 20 members of staff, we currently only use Windows 7 at our Senior School & Moving to Windows 7 at our Prep School in the Summer
    holidays, we would like to find out the route of this problem ideally before then, as we could potentially be doubling the amount of staff with the problem after the move. Has anyone else seen this problem or have a brain wave on how to solve it?
    Regards
    Andy

    Hi Dudleya,
    First of all ,I would suggest to check the permissions of the NTUSER.DAT registry hive .Here is a link for reference :
    The Group Policy Client service failed the logon. Access is denied(Juke Chou`s answer)
    https://social.technet.microsoft.com/Forums/windows/en-US/8c0054a3-35be-4fc4-839c-e2176613eb23/the-group-policy-client-service-failed-the-logon-access-is-denied?forum=w7itpronetworking
    Please refer to this link and add the registry keys to have a check .Please backup the registry keys before you made modifications to them.
    The Group Policy Client Service Failed The Logon In Windows 8(It should also work on windows 7 )
    http://www.thewindowsclub.com/fix-group-policy-client-service-failed-logon-windows-8
    If the issue persists ,we can refer to this link to troubleshoot this issue .
    Troubleshoot User Profiles with Events(It should also be applied to windows 7 )
    https://technet.microsoft.com/en-us/library/jj649075.aspx
    NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
    Best regards

  • Profile Manager Settings for Group does not display for individual members of the group

    Hi there,
    Can anyone confirm whether I am going mad or not, I and new to Mac Server and have set up Profile Manager on OSX Mavericks from scratch and have been using it successfully to deploy enterprise iPads. I have just gone to edit the profile as we wish to increase the timeout time to locking and have been greeted with something strange.
    We have all users in a Group which has settings applied for timeout, pass code change etc. however if I go to an individual account who is part of that group then it isn't showing any settings for that user and it would appear I need to set them again. Similarly if I go to a device belonging to a member of the group then its not showing any settings for that device.
    I would have assumed that if you set restrictions for a group then when you view the restrictions for a member of the group then it would be the same however it appears that you can have a separate payload for a group. Is this the case?
    I am grateful for any advice people can give me.
    Thanks again.
    Rob

    I would have assumed that if you set restrictions for a group then when you view the restrictions for a member of the group then it would be the same
    That was never the way it worked in older versions of 10.3, 10.4, 10.5, 10.6 Server.
    The restrictions for a Group were shown for a Group. The restrictions for a User (alone) were shown for that User.
    And the advantage is that if you see something wrong for a single user, you might be tempted to fix it there, in that user, and when you had changed six of them, you might remember that you meant that to be a group setting after all.
    And the software to implement them separately is simpler, but YOU have to test it to find out the end results of compositing Group and User settings.

  • How to include case stmt in group by clause

    Hi i have a question,
    How do i include a case statement in the group by clause?
    For example:
    Select
    (case when x.ctry is null then y.ctry else x.ctry end) as coo,
    sum (x.in_amt)
    from
    tbl1 x,
    tbl2 y
    where
    x.id = y.id
    group by
    (case when x.ctry is null then y.ctry else x.ctry end)
    Assume, I have got millions of records in both the tables, then my guess is, the above query might take huge time to complete.
    Any alternate method to do this?

    cd/ wrote:
    To remove the expression from the GROUP BY clause. I didn't advocate any performance improvements, did I?No you didn't. And your advice can indeed remove the expression from the GROUP BY clause. But I'm still puzzled as to why that would be a goal in itself.
    Regards,
    Rob.

  • Anyone else having an individual message response (to a group chat) sent to all in the group?

    I have a new Samsung Galaxy S III and noticed right off in Messaging that when I receive an email sent to multiple recipients, the default tab for response is Group conversation.  I changed it to default to Individual messages because my preference is to reply only to the sender.  However, I was surprised to learn that my individual messages are being received by all who received the initial group chat.  This was not the case with my Charge and I can't find any corrective action I can take to prevent it and it is very annoying.  Thanks for sharing similar experiences, especially if you have figured out how to fix it.

    Hi -- no one has offered a fix to the problem.  I posted a single post for multiple friends with the samsung s3 and who are experiencing the same annoying flawed behavior when responding individually to a group chat.  I believe your problem is a bit different but a problem with messaging which seems to indicate a bigger problem with the app and the fact that it is not reliable for its intended purpose.  I still want to be able to send an individual message to the originator of a group chat and I want it to ONLY go to the one who originated the group chat.  I do not want it going to everyone in the group but that is what happens and no setting or resetting that I've tried has corrected the problem.   Thanks for asking.

  • IOS 8 - contact's responses to a group message where I am included being placed in individual thread as opposed to the group thread?

    Has anyone experienced this issue?  Here's an example of what is happening:
    A group message is initiated by my friend that includes myself and 2 Android users.  All of us have group messaging turned on.
    Replies from one of the Android users do not get included in the group thread, but in that person's individual thread within Messages.  The other user's replies are included in the group thread.  My replies are also included in the group thread.
    If I turn off iMessages within the settings menu, the replies from the Android user that were previously going into the individual thread now are included within the group thread.  If I turn back on iMessages, the replies are separated again whenever they are sent, but only from the one Android user.
    Is this a problem with the way the iPhone handles group SMS/MMS messages, or is it an issue with my friend's Android device settings?  What makes me think it's an issue on my end is that things work as intended if I turn iMessages off.
    Thanks in advance for any help!

    Hi,
    In Group chats in iMessages it seems the iMessages server will not allow you to switch the ID being used for one of the contacts (there is no way to tell if the other people in the group chat know this info and whether the Contacts wants it to be known - at least that is the presumption).
    If you want to use his iPhone number then you will have to start a new Chat.
    If his Apple ID is on  his iPhone and of course on his Mac then it can be the case that iMessages will "offer" the pop ups to enable the ID again.
    I find they arrive when I want to do something else and I have to almost dismiss them  to proceed.
    I find that this will activate a Second Apple ID on a second iPhone or the second iPhone number will suddenly appear Active on the Mac's settings for the iMessages account.
    8:16 pm      Sunday; June 29, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Coalesce in the Group by

    I have the need to write in the GROUP BY a column with the COALESCE function.
    If I write the COALESCE or the field ORACLE gives me an error.
    How I should write the COALESCE in the Group BY
    SELECT PCMS_CHDOC_DATA.CH_DOC_ID,
    COUNT(PCMS_CHDOC_DATA_2.CH_DOC_ID) OVER (PARTITION BY PCMS_CHDOC_DATA.CH_DOC_ID) COUNT_ID,
    ROW_NUMBER() OVER (PARTITION BY PCMS_CHDOC_DATA.CH_DOC_ID ORDER BY PCMS_CHDOC_DATA_2.CH_DOC_ID) ROW_NUMBER,
    PCMS_CHDOC_DATA.CH_UID,
    PCMS_CHDOC_DATA.CH_DOC_TYPE,
    PCMS_CHDOC_DATA.STATUS,
    PCMS_CHDOC_DATA.TOOL,
    PCMS_CHDOC_DATA_2.CH_DOC_ID,
    PCMS_CHDOC_DATA_2.CH_UID,
    PCMS_CHDOC_DATA_2.CH_DOC_TYPE,
    PCMS_CHDOC_DATA_2.STATUS,
    PCMS_CHDOC_DATA_2.TOOL,
    PCMS_CHDOC_DATA_2.DROP_TRIGGER,
    PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID,
    PCMS_CHDOC_DETAIL_DESC.CH_UID,
    PCMS_CHDOC_DETAIL_DESC.FILE_VERSION
    COALESCE(PCMS_CHDOC_DETAIL_DESC.DATA, TO_CLOB('See Description above')
    FROM PCMS_CHDOC_DATA,
    PCMS_CHDOC_DATA PCMS_CHDOC_DATA_2,
    PCMS_CHDOC_DETAIL_DESC
    WHERE PCMS_CHDOC_DATA.TOOL='ICD'
    AND PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DATA_2.DROP_TRIGGER
    AND PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID
    AND PCMS_CHDOC_DATA.STATUS <> 'CLOSED'
    GROUP BY PCMS_CHDOC_DATA.CH_DOC_ID,
    PCMS_CHDOC_DATA.CH_UID,
    PCMS_CHDOC_DATA.CH_DOC_TYPE,
    PCMS_CHDOC_DATA.STATUS,
    PCMS_CHDOC_DATA.TOOL,
    PCMS_CHDOC_DATA_2.CH_DOC_ID,
    PCMS_CHDOC_DATA_2.CH_UID,
    PCMS_CHDOC_DATA_2.CH_DOC_TYPE,
    PCMS_CHDOC_DATA_2.STATUS,
    PCMS_CHDOC_DATA_2.TOOL,
    PCMS_CHDOC_DATA_2.DROP_TRIGGER,
    PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID,
    PCMS_CHDOC_DETAIL_DESC.CH_UID,
    PCMS_CHDOC_DETAIL_DESC.FILE_VERSION
    COALESCE ?
    ORDER BY PCMS_CHDOC_DATA.CH_DOC_ID, PCMS_CHDOC_DATA_2.CH_DOC_ID

    I wrote it like this and is working:
    SELECT PCMS_CHDOC_DATA.CH_DOC_ID,
    COUNT(PCMS_CHDOC_DATA_2.CH_DOC_ID) OVER (PARTITION BY PCMS_CHDOC_DATA.CH_DOC_ID) COUNT_ID,
    ROW_NUMBER() OVER (PARTITION BY PCMS_CHDOC_DATA.CH_DOC_ID ORDER BY PCMS_CHDOC_DATA_2.CH_DOC_ID) ROW_NUMBER,
    PCMS_CHDOC_DATA.CH_UID,
    PCMS_CHDOC_DATA.CH_DOC_TYPE,
    PCMS_CHDOC_DATA.STATUS,
    PCMS_CHDOC_DATA.TOOL,
    PCMS_CHDOC_DATA_2.CH_DOC_ID,
    PCMS_CHDOC_DATA_2.CH_UID,
    PCMS_CHDOC_DATA_2.CH_DOC_TYPE,
    PCMS_CHDOC_DATA_2.STATUS,
    PCMS_CHDOC_DATA_2.TOOL,
    PCMS_CHDOC_DATA_2.DROP_TRIGGER,
    PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID,
    PCMS_CHDOC_DETAIL_DESC.CH_UID,
    PCMS_CHDOC_DETAIL_DESC.FILE_VERSION,
    ( SELECT COALESCE(PCMS_CHDOC_DETAIL_DESC.DATA, TO_CLOB('AAA'))
    FROM PCMS_CHDOC_DETAIL_DESC
    WHERE PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID
    ) DATA
    FROM PCMS_CHDOC_DATA,
    PCMS_CHDOC_DATA PCMS_CHDOC_DATA_2,
    PCMS_CHDOC_DETAIL_DESC
    WHERE PCMS_CHDOC_DATA.TOOL='ICD'
    AND PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DATA_2.DROP_TRIGGER
    AND PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID
    AND PCMS_CHDOC_DATA.STATUS <> 'CLOSED'
    GROUP BY PCMS_CHDOC_DATA.CH_DOC_ID,
    PCMS_CHDOC_DATA.CH_UID,
    PCMS_CHDOC_DATA.CH_DOC_TYPE,
    PCMS_CHDOC_DATA.STATUS,
    PCMS_CHDOC_DATA.TOOL,
    PCMS_CHDOC_DATA_2.CH_DOC_ID,
    PCMS_CHDOC_DATA_2.CH_UID,
    PCMS_CHDOC_DATA_2.CH_DOC_TYPE,
    PCMS_CHDOC_DATA_2.STATUS,
    PCMS_CHDOC_DATA_2.TOOL,
    PCMS_CHDOC_DATA_2.DROP_TRIGGER,
    PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID,
    PCMS_CHDOC_DETAIL_DESC.CH_UID,
    PCMS_CHDOC_DETAIL_DESC.FILE_VERSION
    ORDER BY PCMS_CHDOC_DATA.CH_DOC_ID, PCMS_CHDOC_DATA_2.CH_DOC_ID
    But now the problem is another, I would like to insert the CASE like this:
    case when row_number > 1 then 'null'
    else ( SELECT COALESCE(PCMS_CHDOC_DETAIL_DESC.DATA, TO_CLOB('AAA'))
    FROM PCMS_CHDOC_DETAIL_DESC
    WHERE PCMS_CHDOC_DATA.CH_DOC_ID = PCMS_CHDOC_DETAIL_DESC.CH_DOC_ID
    ) DATA
    end
    Is correct?

  • How I check in group by query the group change

    How I check in group by query the group change
    Hi master
    Sir I have master detail table
    This is my query
    select rownum,chartofacc.accid,title,nvl(drbal,0),nvl(crbal,0),
    (select case when nvl(sum(debit),0)-nvl(sum(credit),0)>0 then
    nvl(sum(debit),0)-nvl(sum(credit),0)
    else
    0
    end mfadrttt
    from voudetail where voudetail.accid=chartofacc.accid) as mfadr,
    (select case when nvl(sum(credit),0)-nvl(sum(debit),0)>0 then
    nvl(sum(credit),0)-nvl(sum(debit),0)
    else
    0
    end mfacrttt
    from voudetail where voudetail.accid=chartofacc.accid) as mfacr
    ,nvl(debit,0),nvl(credit,0),voumaster.entdate,voumaster.vno from chartofacc ,accbal,voudetail,voumaster where chartofacc.accid=accbal.accid(+) and chartofacc.accid=voudetail.accid(+) and voumaster.vno=voudetail.vno order by chartofacc.accid,voumaster.entdate,voudetail.VNO;
    Sir I need add opbal from master section to debit in detail section when new group start only after adding I use that column for accumulative total or running balance
    If I get any method when group change system give me any key or indication then I use
    Please give me idea in both field oracle sql and oracle report 6i
    Thank
    aamir

    Hi,
    Please send tables structures and sample data from that tables. And, of course what should be the output. :) Just sending your query won't help us to find a solution.
    Peter D.

  • Case Statement and Group By issues

    Hi this is my initial query which works perfectly:
    select ff.cla_case_no, Cost_before_Decision, Cost_Of_Claim, decline, Decline_Description from
    fraud_nov_14_final ff
    ,(select cla_case_no, (sum(total_cost_adj_old) + sum(decline_estimate)) Cost_before_Decision
    from reporting.ci_final@test
    group by cla_case_no) z
    where ff.cla_case_no = z.cla_case_noI now want to add in a condition based on a column called decline:
    select ff.cla_case_no, Cost_before_Decision, Cost_Of_Claim, ff.decline, Decline_Description from
    fraud_nov_14_final ff
    ,(select cla_case_no, (case when decline = 1 or decline = 2  THEN (sum(total_cost_adj_old) + sum(decline_estimate)) ELSE Total_Cost END) Cost_before_Decision
    from reporting.ci_final@test
    group by cla_case_no) z
    where ff.cla_case_no = z.cla_case_noThe error message I receive is :
    ORA-00979: not a GROUP BY expression
    00979. 00000 - "not a GROUP BY expression"
    Thanks in advance for your help!!
    Banner:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    You would need DECLINE in the group by clause of your inner query.
    Additionally you would need to change TOTAL_COST to SUM(TOTAL_COST) in where case statement.
    But then you would retrieve one row for each value of DECLINE in this query.
    You also could use this:
    (I don't know if it will meet your requirements)
    SELECT ff.cla_case_no,
                     cost_before_decision,
                     cost_of_claim,
                     ff.decline,
                     decline_description
      FROM fraud_nov_14_final ff,
                     (SELECT   cla_case_no,
                               SUM (decode(decline,1,total_cost_adj_old+decline_estimate,
                                                   2,total_cost_adj_old+decline_estimate,
                                                   total_cost))  cost_before_decision
                                    FROM reporting.ci_final@test
                      GROUP BY cla_case_no) z
    WHERE ff.cla_case_no = z.cla_case_no;(untested code, because I don't have your tables)
    Edited by: hm on 23.11.2011 06:52

  • Case statement with group by clause

    SELECT STP, CASE WHEN Alternate IS NULL THEN 3 ELSE 4 END as Ind,
    CASE WHEN Alternate IS NULL THEN 'New Address' ELSE 'New Location' END as Description , Count(*) Rec_Cnt
    FROM t_Ids
    group by STP, CASE WHEN Alternate IS NULL THEN 3 ELSE 4 END, CASE WHEN Alternate IS NULL THEN 'New Address' ELSE 'New Location'
    ORDER BY 1,2,3
    I need a query something like this. Does anyone has any idea on this???

    You're missing the END on the GROUP BY Case statement, but otherwise this looks fine.
    What problem are you having?
    Also, please post DDL
    Thanks
    Carl

Maybe you are looking for

  • Why ResultSet getDate() method returns null when querying .csv file?

    Here is the full code: import java.sql.*; import java.sql.Types; import java.sql.Date; import myjava.support.CachedRowSetMaker; import javax.sql.rowset.CachedRowSet; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Cale

  • Regd.  FM : RS_VARIANT_VALUES_TECH_DATA

    I have a small query  regarding the  FM : RS_VARIANT_VALUES_TECH_DATA is used To get the values of a variant u2026u2026. First i want to know the exact variable in the return table  VARIANT_VALUES to set the printer out put device as LOCL I am unable

  • RMAN BACKUP hangs up on archive logs

    Hi, in 9i on Linux, My rman backup script is : RMAN> run { 2> allocate channel t1 type disk; 3> backup incremental level=0 format '/mnt/rman/MYDB/full_%d_%t_%s_%p' database; 4> sql 'alter system switch logfile'; 5> backup format '/mnt/rman/MYDB/al_%d

  • I need a simple counter

    Hi everybody, I need a counter so that when ever i press the submit button continuously it should display the number starting from 1, can anybody help me with the simple code

  • Manual for GBIP-232CT.64K RS232 to GPIB converter

    I'm trying to locate a product manual for an "older" style GPIB to RS232 converter box. The part number on the box is GPIB-232CT.64K (180450-01 Rev B2).