CASE WITH COUNT

SELECT ACTV_DESC,
ACTV_CDE,
CNT_ACTV_CDE,
CASE WHEN VET_OTHR_ELIG_CDE IN ('02','03','04') THEN 'YES' ELSE NULL END AS VET_YES, -- Instead of Displaying 'YES' Like here what iam doing
i want to display the Count value
CASE WHEN VET_OTHR_ELIG_CDE ='01' THEN 'NO' ELSE NULL END AS VET_NO -- same here instead of displaying No i want to display here how many non veterans are there .
FROM
(SELECT
E.ACTV_DESC AS ACTV_DESC,
E.ACTV_CDE AS ACTV_CDE,
B.VET_OTHR_ELIG_CDE AS VET_OTHR_ELIG_CDE ,
COUNT(E.ACTV_CDE) AS CNT_ACTV_CDE
/*CASE WHEN B.VET_OTHR_ELIG_CDE = '01' THEN 'No'
WHEN B.VET_OTHR_ELIG_CDE IN ('02','03','04') THEN 'Yes'
WHEN B.VET_OTHR_ELIG_CDE IS NULL THEN ' '
END AS VETERAN*/
FROM
ETR_RGT_PARTC A,
ETR_INT_PARTC_INTK_JS B,
ETR_SDT_PARTC_PGM_ACTV C,
ETR_VM_SM_STFFNME D,
ETR_SMT_ACTV_MSTR E
WHERE
A.PARTC_ID = B.PARTC_ID AND
B.PARTC_ID = C.PARTC_ID AND
B.APPLC_ID = C.APPLC_ID AND
B.PGM_ID = C.PGM_ID AND
C.RESP_STFF_ID = D.STFF_ID AND
C.PGM_ID = E.PGM_ID AND
C.ACTV_ID = E.ACTV_ID AND
(D.RACF_ID LIKE :P_RACF_ID||'%') AND
C.LOC_ID LIKE 'ES%' AND
(TRUNC(C.CRTE_DTE) >= :P_FROM_DATE AND
TRUNC(C.CRTE_DTE) <=:P_TO_DATE) AND
D.STFF_LOC_ID = 'ES00'||:P_LOCL_OFFC_ID
AND D.CLOS_DTE IS NULL
GROUP BY
ACTV_DESC,
ACTV_CDE,
B.VET_OTHR_ELIG_CDE
ORDER BY ACTV_CDE)a;
please refere the query comments can anyone help on this ...

may be this?
****not tested
SELECT   E.ACTV_DESC AS ACTV_DESC,
         E.ACTV_CDE AS ACTV_CDE,
         B.VET_OTHR_ELIG_CDE AS VET_OTHR_ELIG_CDE,
         SUM (CASE
                WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1
              END) AS VET_YES,
         SUM (CASE
                WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1
              END) VET_NO,
         COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
    FROM ETR_RGT_PARTC A,
         ETR_INT_PARTC_INTK_JS B,
         ETR_SDT_PARTC_PGM_ACTV C,
         ETR_VM_SM_STFFNME D,
         ETR_SMT_ACTV_MSTR E
   WHERE A.PARTC_ID = B.PARTC_ID
     AND B.PARTC_ID = C.PARTC_ID
     AND B.APPLC_ID = C.APPLC_ID
     AND B.PGM_ID = C.PGM_ID
     AND C.RESP_STFF_ID = D.STFF_ID
     AND C.PGM_ID = E.PGM_ID
     AND C.ACTV_ID = E.ACTV_ID
     AND (D.RACF_ID LIKE :P_RACF_ID || '%')
     AND C.LOC_ID LIKE 'ES%'
     AND (TRUNC (C.CRTE_DTE) >= :P_FROM_DATE
          AND TRUNC (C.CRTE_DTE) <= :P_TO_DATE)
     AND D.STFF_LOC_ID = 'ES00' || :P_LOCL_OFFC_ID
     AND D.CLOS_DTE IS NULL
GROUP BY ACTV_DESC,
         ACTV_CDE,
         B.VET_OTHR_ELIG_CDE
ORDER BY ACTV_CDE

Similar Messages

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • Pulsewidth data logging with counter channel

    Hello everyone.
    i have query with data logging of pulse duration measured with counter input into .lvm file
    pulse signal contain frequency of 100 hz with pulse duration vary from 2 to 8 ms
     i want to log pulse duration in .lvm file.
    when running vi(below screen shot) i find data logg with duplicate instance of time.
    i want to log pulse duration data with every ridging or falling edge of pulse.
    so if i run vi for 20 sec i sould have 2000 reading of pulse duration in my.lvm file with appropriate time  in time column
    Attachments:
    pulsewidth using counter.jpg ‏659 KB

    Hello Karthik,
    I can think of two ways I would approach this. One would use software timing, and the other would use hardware timing.
    1. Software timing: This might be the easiest approach. The idea is you would use your example much as it is written, then use a loop with a delay as the "Time between samples" to call your counting code over and over. In this case, I have a few suggestions for your code. First, instead of the loop, you could start the counter, use a delay in a sequence structure (use "Wait (ms)", not "Wait Until Next ms Multiple")for your "Sampling time", then read the counter and stop. After the stop you'll need another "Wait (ms)" in a sequence structure for your "Time between samples". Finally, wrap a loop around all of this to r
    epeat it. One advantage of this approach is the user can change the between time on the fly.
    2. Hardware timing: The idea behind this would be to use two counters. The first would count, the output of the second would be wired to the gate of the first to control when the first counts. The second counter would be programmed to output a pulse train where the positive portion of the pulse would be your "Sampling time" and the negative portion would be your "Time between samples". The creative part for this approach would be figuring out when to read the count. One way to do this would be to also connect the gate of the second counter to an analog input, then read the count whenever the input goes low (say, below 1 volt). This approach might be the more accurate of the two. However, you would always be getting a total count, so you would have to subract the previous count each time. Also, you would not be able to change your sampling time or between time once you start.
    Finally
    I'd suggest looking at some examples - you can usually find code to help you.
    Best Regards,
    Doug Norman

  • IPod nano case with protective screen, available in store (looking for one)

    Hey, im looking forward to buy my first mp3 player, and its gonna be a white iPod Nano. I read alot of reviews, and some people have problems with scratches, and their screen cracking. I am really concerned about the screen cracking.
    Is there a good quality protective case with a screen protector, (maybe a wheel protecter, not noccesary though), that is sold at major stores (wal-mart, circuit city, bestbuy, etc)? Price can be an issue too, so not too expensive. Thanks in advance!
    pc   Windows XP  

    http://www.walmart.com/catalog/product.do?product_id=4328727
    would this be a good case?

  • Will Tablet case with combined keyboard work on Lenovo Ideapad A1 07

    Hi All,
    Sorry if anyone has asked before but couldn't find specific.
    My wife has recently purchased a Lenovo Ideapad A1 07 for its size,  a friend who has a small android tablet also recommended to her, to buy a tablet case with combined keyboard with USB connection from amazon. When received the connection obviously doesn't fit, so I started searching around web for an adapter for it, but I’m seeing conflicting info that the ideapad either does/doesn't support USB data transfer connection point, so before buying an adapter what is correct!.
    Can anyone throw some light onto whether Lenovo will update the firmware to be able to use USB at any time or has anyone have a work around. Any help and advice to get this keyboard working would be grateful as the tablet is a great little device for her.
    Gazzataf  

    If you are patient, go through the reviews of a specific USB keyboard that was suggested as an addition for Lenovo A1 by Amazon: You will see that even though users have tried different cables and adapters, no A1 user has managed to get this working on his tablet.
    This issue may be solved by a future upgrade (if any), which will enable the USB OTG feature of the microUSB port of the A1 tablet. Until then, nothing can be done in order to have any USB device identified and working with A1. I really hope that I make a mistake here and that someone will come up with a working soultion for this issue ...

  • Create case with vi:s from folder

    I want to create a case with n number of sub vi inside. I have a folder containing n number of vi:s, they all have the same inputs and outputs.
    My problem is that I dont know how many there is and I want to be able to open a specific one depending on its name in a string, send in some parameters and get some back.
    Is there any way to create a case on startupp that has as many frames as there are vi:s in the folder, give the case frame the name of the vi, add the vi icon in the case and connect the wires to it. Or is this possible to do in an outher way? Calling it some way?
    /Richard
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Use scripting to generate your case. This would require a scripting license if you're using LabVIEW 8.x. Also, scripting is beyond the scope of these forums. If you want to learn more you can head over to LAVA. 
    Just want to clarify before people start calling NI about it. There is no such thing as a scripting license. This product does not exist, so let's all please stop talking about this imaginary license. Scripting is an internal feature of LabVIEW reserved for internal use only and NI does not want people to use it. NI makes it difficult for anyone to use and access. This is done on purpose. The only way to get access to it is to hack LabVIEW. Some have managed to do this and have posted their findings and experiments on LAVA. Using scripting techniques is totally unsupported by NI.
    On the other hand, it's a great tool for doing some amazingly cool stuff in LabVIEW.
    Michael Aivaliotis
    VI Shots LLC

  • Best Cooling Tower Case With Handles

    I'm trying to build a computer that will run Premiere Pro CS 5.5 and other programs.
    From reading on these forums, it looks like the best options for me right now are:
    i7 2600K
    Asus Sabertooth P67
    GTX 570
    16GB Patriot 1333MHz RAM
    Windows 7 Home
    500GB hard drive for the system and programs and page file
    Four 1TB drives in two RAID-0 configuations
    I'm probably not going to overclock right now because I don't want to be so concerned with overheating.  I may try overclocking later.
    I got some prices at Fry's, which includes the Corsair 600T Tower Case.
    I have 2 questions:
    1. I read on a forum that a guy was having problems with cooling on the 600T and another person said the 20mm fans are too small, that 30mm are better.
    2. I'm also trying to find a case that has a handle (or handles) so that I can transport it easily back and forth to another location.
    I've read here to stay away from the small or mini towers because they don't cool well enough and that makes sense to me.
    I only saw one at Fry's that had a handle, but I can't remember the name of it.
    I like the Mac Pro tower style handles.  Good and solid.
    Anyone know of a case that is:
    1. Great for cooling the above configuration, and
    2. Has a handle?
    Any feedback on the other componenets would be great as well.
    Thanks for any help or advice.

    Flyingfish,
    I can think of two pretty good possibilities for a luggable (mid or larger) case with a handle, and I'm sure there are others out there as well (Google LAN party):
    Thermaltake V5 Black Edition Mid-tower Gaming Case (has nice full handle)
    Any mid or full tower case + Sunbeam LAN Party Bag (includes strong straps that go around case to carry any case and keyboard using backpack style straps, shoulder strap, or a handle)
    Don't scrimp on cooling, even if you do not plan on overclocking; look for a dual fan heat pipe style that will fit with whatever case you do choose. Good cooling will keep your rendering reliable and will allow for the 2600k to "turbo" (speed itself up) more effectively.
    Now, regarding your component list, it looks just great! Don't forget a 850 watt p/s from a solid manufacturer. Also, skip the Corsair 600T; I brought one home I liked the design so well, then returned it when I realized the fans were not up there with the best fans and the typical high-quality replacement fans (Scythe Gentle Typhoon, etc.) do not fit without starting to drill holes, etc.
    Jim

  • Macbook Air case with magnets. Will it affect hardware or performance of product?

    Macbook Air case with magnets. Will it affect hardware or performance of product?

    No, the low power N30 or N35 gauss neodymium magnets in the magnetic flap cases will not affect it.
    There is no HD, and the SSD are hard (relatively) to corrupt by magnetic field unless high gauss and at close proximity.

  • IPOD CASES WITH MAGNETS

    i have often heard (i still don't know if it's true...) that magnets are very dangerous near your computer or hard drives. i want to purchase an ipod case with a flip cover that contains magnets in it. has anyone had a problem with a case like this or is this sort of thing alright?

    case with magnet button or whatever?
    you should be fine, never had problems

  • Case with Magnets - any Impact on iPhone 5?

    Hi@All!
    I bought a Case with Magnets to close for my iPhone 5. Does it have any Impact?
    Tranks for help in advance.
    Klaus

    no not at all
    magnets if powerful enough pasive magnets are not powerful enough but strong electromagnets can damage magnetic storage such as a harddisk
    but no ios devices use magnetic storage they use flash storage

  • Where can I buy an ipad2 case with the same design as the case for the original ipad?

    I thought the case for the original ipad was great, but it doesn't quite fit the ipad2.  Is there somewhere I can find a case with that same design, but fitted for the ipad2?

    www.amazon.com
    Search for "iPad 2 Case"

  • Xy graph , i have case with generated diferent arrays

    Hello
    I have case with A.B.C.D... options, each of this options creating different arrays wich can i want to display to the same xy graph. How can i create same graph in the diferent case ? When i creating second graph , this graph have different name a create me new graph, when i change name of graph then first , name was changed but it is not same graph.
    thanks

    Hi
    use a property node/ local variable of the xy Graph in each case and update its value
    Regards
    Dev
    Attachments:
    multi property node_xy.vi ‏42 KB

  • Single cycle plan with counter in plant maintenance

    Dear Experts,
    I am creating single cycle plant with performance based with couter reading.
    1 I have crated a measuring point with counter in running hrs
    2 Created a single cycle plan and given the couter no. there
    3 Since i hv given 4000 hrs in plan, as soon as i update the document there should be a notification but it is not happening
    Can any one clarify the issue
    Thanks&Regards
    N.Chandrasekhar

    Dear thyagarajan,
    1 I hv created meas point with counter with specified equip
    2 made document for that of 10 hrs
    3 Created a  single cycle plan giving reference same equip Cycly given 250 hrs, Entered the counter no there, call horizon 100, schedule 365 days.... while saving given no to save.....while scheduling IP10,
    taken the counter ducument which i 1st saved 10 hrs... thn called 1st call and released and saved.
    4. here with out entering that 250 hrs in ducument i am getting the notification............?
    5. I have to get the notification after entering 250 only..
    Why is happening like that
    Hope you have under the issue
    Regards
    N.Chandraasekhar

  • Move test case with referenced items to another project

    How can I move a test case with all referenced contexts and verifications from a project to another project? At the moment I have to move each single item. How can I do this more efficient?

    Hi Markus,
    You can Export/Import it in a Test Portable format.
    All contexts will be included.
    Kind regards,
    Ulyana.

  • Case with Keyboard Will Not Work on my HP 7"1800 Android Tablet

    I baught a HP 7" 1800 android  tablet and I resently baught a case with a keyboard and I can not get it to work. I have tryed every thing that I know to get it to work but it will not work! I would like to know how to get this keyboard in my case to work? Has anyone got any sugestions? 

    Is the keyboard using a cable or BlueTooth?  If a cable, it will not work. If using BlueTooth, I would re-read the instructions provided with the keyboard. 1. Be sure the keyboard is compatible with Android.  This should be stated in the instructions somewhere. 2. Put the keyboard into "pairing mode" per the instructions.  This usually requires specific button presses. 3. Be sure BlueTooth is turned on in your tablet, and you have told it to "Scan for new devices" while the keyboard is in pairing mode. I have successfully used an old Palm Inc. BlueTooth keyboard with many HP tablets. WyreNut

Maybe you are looking for