Count numbers

Hi,
i need to count the number 'Adult' and 'Child' in this query handling with case statement.
could anyone help me.
select ppf.employee_number
,ppf.full_name emp_name
,papf.full_name dependent_name
,hrl.meaning
,case when trunc (months_between (to_date(pac.segment10,'YYYY/MM/DD HH24:MI:SS'),papf.date_of_birth)/ 12) > 12 then 'Adult'
when trunc (months_between (to_date(pac.segment10,'YYYY/MM/DD HH24:MI:SS'),papf.date_of_birth)/ 12) <= 12 then 'Child'
end as Adult_Child
,papf.date_of_birth dependents_dob
,ppa.date_from ticket_start_date
,ppa.date_to ticket_end_date
,trunc (months_between (ppf.effective_start_date,papf.date_of_birth)/ 12) age
,to_date(pac.segment10,'yyyy/mm/dd hh24:mi:ss') Date_of_Issue
,pac.segment14 Ticket_Value
,pac.segment8 No_Of_Adults
,pac.segment9 No_Of_Childs
,case when pac.segment16 = 'TK' then 'Ticket'
when pac.segment16 = 'EN' then 'Cash'
end as Ticket
,pcr.contact_person_id
from per_people_f ppf, per_person_analyses ppa, per_analysis_criteria pac, per_contact_relationships pcr
,per_all_people_f papf, per_special_info_types_v pst, hr_lookups hrl
where ppf.person_id = ppa.person_id
and ppa.analysis_criteria_id = pac.analysis_criteria_id
and ppf.person_id = pcr.person_id
and pcr.contact_person_id = papf.person_id
and hrl.lookup_code = pcr.contact_type
and hrl.lookup_type = 'CONTACT'
and trunc(sysdate) between ppf.effective_start_date and ppf.effective_end_date
and ppa.id_flex_num = pst.id_flex_num
and pst.enabled_flag = 'Y'
and ppf.employee_number = :p_emp_number
and ppa.date_from >= nvl('01-jan-2006', to_date('01-jan-1900','dd-mon-yyyy'))
and ppa.date_to <= nvl('31-aug-2009',to_date('31-dec-4712','dd-mon-yyyy'))
order by to_number(ppf.employee_number)
thanks in Advance
Mohammed Khaleel

SELECT SUM (DECODE (adult_child, 'Adult', 1, 0)) adult_count, SUM (DECODE (adult_child, 'Child', 1, 0)) child_count
FROM (SELECT ppf.employee_number,
            ppf.full_name emp_name,
            papf.full_name dependent_name,
            hrl.meaning,
            CASE
               WHEN TRUNC(MONTHS_BETWEEN (TO_DATE (pac.segment10, 'YYYY/MM/DD HH24:MI:SS'), papf.date_of_birth) / 12) > 12 THEN 'Adult'
               WHEN TRUNC (MONTHS_BETWEEN (TO_DATE (pac.segment10, 'YYYY/MM/DD HH24:MI:SS'), papf.date_of_birth) / 12) <= 12 THEN 'Child'
            END
               AS adult_child,
            papf.date_of_birth dependents_dob,
            ppa.date_from ticket_start_date,
            ppa.date_to ticket_end_date,
            TRUNC (MONTHS_BETWEEN (ppf.effective_start_date, papf.date_of_birth) / 12) age,
            TO_DATE (pac.segment10, 'yyyy/mm/dd hh24:mi:ss') date_of_issue,
            pac.segment14 ticket_value,
            pac.segment8 no_of_adults,
            pac.segment9 no_of_childs,
            CASE
               WHEN pac.segment16 = 'TK' THEN 'Ticket'
               WHEN pac.segment16 = 'EN' THEN 'Cash'
            END
               AS ticket,
            pcr.contact_person_id
      FROM per_people_f ppf,
           per_person_analyses ppa,
           per_analysis_criteria pac,
           per_contact_relationships pcr,
           per_all_people_f papf,
           per_special_info_types_v pst,
           hr_lookups hrl
      WHERE ppf.person_id = ppa.person_id
            AND ppa.analysis_criteria_id = pac.analysis_criteria_id
            AND ppf.person_id = pcr.person_id
            AND pcr.contact_person_id = papf.person_id
            AND hrl.lookup_code = pcr.contact_type
            AND hrl.lookup_type = 'CONTACT'
            AND TRUNC (SYSDATE) BETWEEN ppf.effective_start_date AND ppf.effective_end_date
            AND ppa.id_flex_num = pst.id_flex_num
            AND pst.enabled_flag = 'Y'
            AND ppf.employee_number = :p_emp_number
            AND ppa.date_from >= NVL ('01-jan-2006', TO_DATE ('01-jan-1900', 'dd-mon-yyyy'))
            AND ppa.date_to <= NVL ('31-aug-2009', TO_DATE ('31-dec-4712', 'dd-mon-yyyy'))
      ORDER BY TO_NUMBER (ppf.employee_number))Regards,
Mahesh Kaila

Similar Messages

  • How do I count numbers within a specific range in a column?

    I'm creating a spreadsheet for my college courses where I enter each score from each class as I get them back and it continues to recalculate my grades in each course.  Now I'm on the part where I want to make a box that calculates the current GPA for the semester.  I know how I'm going to do it already but I need to figure one thing out first.  Say my scores are as follows:
    85.50%
    82.00%
    92.35%
    94.25%
    78.00%
    I need a working code that counts the amount of scores within a certain range, say for example, tell me how many scores are between 80.00 and 89.99.  I can figure out how many are above/below a certain value (80.00 again for example) with a code like this [scores being the column with the grades]:
    =COUNTIF(Scores,">=80.00") ---- this gives me "4" correctly
    BUT when I add another value and want it to limit scores to not just being equal to/above 80.00 but also below 90.00 it freaks out.  I tried the two following codes:
    =COUNTIF(Scores,">=80.00","<90.00")
    =COUNTIF(Scores,">=80.00",Scores,"<90.00")
    Neither work, i'm sure i'm just wording it wrong.  It should obviously spit out the number "2" with there being two B's.  Any help would be appreciated!

    Jeremy.Osborne wrote:
    I have set up a chart just like yours with the intervals (60-100) on the left and on the right I have no idea what to do.  Do I enter that code into each box? Right now it looks like:
    =INDEX(FREQUENCY(Scores, I have no idea what to put here)
    Jeremy,
    in my response, I gave you the expression I used to build the frequency table. It was:
    =INDEX(FREQUENCY(Data :: A,A),ROW()-1)
    If you build a document exactly as the one I illustrated, the same expression will work for you. If you use a different table name, you will have to adjust the reference.
    Regarding the COUNTIFS function, you must read carefully the syntax defined in the Function Browser or the Formulas and Functions user guide and follow it to the letter.
    Jerry

  • Downloads and Podcasts count numbers/fields are blank

    The number field that is next to podcasts (the number of unplayed episodes in library) is blank... just an empty oval.
    The same thing is true of my Downloads count.
    If I were to open the Podcasts or Download windows, everything shows up, but under the regular view they are blank.
    My iTunes library is on an external HD connected via Firewire.
    I use the same library on another computer, and there the counts are fine. Both computers have the same version of iTunes running, 8.0.2.
    Should I delete my Preferences file on the one computer? Which file would it be... User/Library/com.apple.iTunes.plist?

    Not really answered, but no longer an issue.

  • Counting Numbers Returned from a query

    I am running a command using VMM 2012:
    Get-VMHost -ComputerName HV07-BH | Get-VM | Select-Object CPUCount
    It returns. I need to add the numbers listed below to get a total of 29 in a single command. I am unsure of how to do this. Any ideas would be appreciated.
     CPUCount
            2
           16
            2
            1
            2
            6

    I answerered this in the other thread you made, but in case you only check this one:
    You need to use "Measure-Object, like this (note that Select-Object is removed since it isn't needed):
    Get-VMHost -ComputerName HV07-BH | Get-VM | Measure-Object -Sum CPUCount
    Note that his gives the result in a Microsoft.PowerShell.Commands.GenericMeasureInfo type. If you ONLY want the sum as an int/string do it like this:
    Get-VMHost -ComputerName HV07-BH | Get-VM | Measure-Object -Sum CPUCount | Select-Object -ExpandProperty Sum

  • Itunes 11 change play counts numbers

    Is there any way to change play counts or merge two songs play counts when you find out you have the same song twice in your librairie? By the way I subscribed to iTunes match... if this may change something...

    I don't know any way to merge play counts automatically, but you can increase the play count of a song pretty easily.  Play it, jump to the last few seconds of the song, then let it end.  This will update your play count.  Repeat as many times as necessary until the count equals the total number of plays between the two copies.  Then delete one of the copies.  A little laborious, but it'll get the job done.

  • Looping and counting numbers

    Can anyone please help, I am trying to write a method where a while loop adds up all the numbers between two numbers. I am passing the numbers to the method as parameters.
    So far I can add the numbers in as parameters fine and have stored them as local variables. I can perform calculations on the numbers stored but cannot get them to add up the range of numbers for example is the first number is 5 and second is 7, I want the sum to add 5 + 6 + 7
    Thanks

    Spangle1187 wrote:
    Someone who I don't know from Adam decides to change the title of a post to spoonfeeding. How do you expect to take it? No you are right people do not provide full answers to questions that easily. That is why I thanked him in the reply for his answer. I just don't understand why then the need to change in the title.Again, he changed the title of his post. You can change your next post title to "Spangle1187 is Amazing" if you want (that just gave me an idea). And like I said, he changed his post (I assume) to poke fun of himself for doing something out of the norm, in a friendly way. Good luck getting an answer that easily here again, after the attitude you've displayed here.
    As for the personal dig, I was having an exchange of opinion with someone about the above and somebody else decides to change my user name in an attempt of a joke or a direct response to my not liking the spoonfeeding comments? Why would you do this to a stranger.He didn't "decide" to change it. He couldn't if he wanted to. He joked about changing it, because (again, I assume) of your overwhelmingly inappropriate overreaction to the changing of a post title. If this is the worst thing that happens to you on the internet (or in real life, for that matter), then you've been living a sheltered life.
    This board is a wealth of information but the forum does not seem to be that friendlyEverything that you're taking exception to was done in a friendly, poking-fun kind of way. Ridiculous.

  • Seeing counter numbers

    Sorry if this is a stupid question...With the old Homepage I can see all the counter readings on the .Mac webpage (or by clicking More to see those lower down the list). How can I see the counter readings from my iWeb pages without going to the actual webpages? Only the top 5 show on the .Mac page.
    Thanks a lot
    James

    You can't Not without visiting the page itself anyway.
    You may want to check out statcounter.com
    Directions to add it to iWeb pages:
    http://www.varkgirl.com/Varkgirl/Selective%20Statcounter.html

  • Page count /numbering issue

    Hello,
    I have a document that needs to have the page number increment only on every left page.
    i.e.
    first left page has page 1
    first right page has page 1
    second left page has page 2
    second right page has page 2
    third left page has page 3
    third right page has page 3
    etc.
    Is there a way to do this?
    Thanks,
    Robbie.

    Is the Japanese and English in separate flows? If so, you can use your existing document as a master document, which you can print as is to show both languages. Forget the idea of having the same page number on right and left pages. Just let the page numbers flow as normal.
    Then create two other documents, one for English and one for Japanese, each with the appropriate headers. In each document, you text inset only one of the flows from the master document, which FrameMaker allows you to do. Then print each separately. Each will have the correct page numbers and the correct headings. Any edits you need to make are done in the master document, then update the text insets in the single documents.
    In this scenario, you have three separate documents but there is really only one that contains the content. AND no need to conditionalize anything.
    Van

  • Counting numbers of LEDs

    hello there,
    what i am trying to do is i want to calculate the number of the green LEDs and the red LEDs of an array and display it in the front panel as shown on the file attached. Any one can help please? Another thing, how to write to file from 3d array ? 
    Solved!
    Go to Solution.
    Attachments:
    Parking.vi ‏15 KB

    If you don't know the size of the Boolean array then you simply work backwards, keep count and subtract. (parking3)
    Or use array size add them up and subtract (parking4)
    You do not even need the inner loop (parking5)
    Attachments:
    Parking3.vi ‏15 KB
    Parking4.vi ‏16 KB
    Parking5.vi ‏15 KB

  • Nidaq Counter Numbers for PCI6601

    I am trying to interface my application to a PCI6601, but keep getting -10121 errors with the GPCTR_Control and GPCTR_Set_Application Nidaq functions. I am sending the Board number as a short, Counter number as a Cstring(Null terminated), with a value of ND_COUNTER_0, and an action of type Cstring(null terminated), value ND_RESET. I am using Nidaq Version 6.9.2. What am I doing wrong?

    Hello;
    Without seeing the code, we can't predict where the problem is. However, you can use one of the NI-DAQ shipping example as start point for your development, and then change the code as your application requires.
    You can start with the one named "TIOEventCountwithFilt.c" that you can find at C:\Program Files\National Instruments\NI-DAQ\examples\VisualC\Ctr.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National Instruments

  • Counting decimal numbers remove leading zero

    Hello:
    I'm counting numbers down using the Numbers effect, from 1 dollar down to .77, but I don't want a leading zero. I have it set to two decimal places but it keeps the zero and shows it as 0.77.
    Is there a way to get rid of the zero?

    You could just mask it out after splitting the layer suitably? Otherwise this is still a good alternative:
    Dan Ebberts's Expressioneering Design Guide
    Mylenium

  • Hit Counter For Web Site Now Working?

    I have a web site that was published with iWeb 06. I am using a domain name at GoDaddy and forwarding to .Mac using masking so the site shows with the domain name not the .Mac address. If you went to the site by entering the domain name the hit counter on the first page would not show. However, if you entered the .Mac address to go to the site the counter would show.
    Well the site was republished and upgraded with iWeb 08. Recently I noticed that the hit counter now shows regardless of how you go to the site. I was pleasantly surprised but when did this happen? Of course as others have noticed, on my .Mac home page on the side bar where the website pages are listed the counter numbers no longer show. So they took something away and gave something back?
    John

    I don't think Apple meant to take away the .Mac counter section of the .Mac page. I think it's a bug that they have yet to resolve. It would be interesting to see if anyone has asked Apple about this and if they gave a definitive answer?

  • ITunes doubling play counts after being listened to on iPhone 5

    I just synced my phone to my iTunes after playing an album only once on my iPhone 5 and I noticed that my iTunes play count is showing that each song has actually been listened to twice. Same goes for a song that I played four times, the play count says that it was played eight times. Is this a new glitch/is there a way to fix this? I rely heavily on my play count numbers for playlists and sorting my music. Any help?

    See this page - Itunes playcount too high
    Looks like a few people are having the issue aswell.
    It appears that the iPhone and iTunes are holding two seperate play counters. Whenever you sync the phone, the play count on the phone should reset everything to zero. What is actually happening is that the iPhones play count and iTunes play count are adding together these numbers - hence the large increase in play count.
    So, if you listen to a song once and then sync the phone - play count will be 1. If you then do the same - it jumps up to 3. Again, playing the song again - will increase the count to 5.
    I've had this issue ever since iOS 8 and a few of my songs in iTunes have over 1300 plays... Fairly sure I didn't leave the song on repeat and let it play for 5 days straight...

  • How to create formula to count caracters

    dear
    I'am trying to count al the workorders that are still open per week
    does anyone have an idea?
    While searching I found out that crystal reports is only counting numbers?
    Gracia
    Edited by: Pimcia on Aug 6, 2009 5:18 PM

    Slighlty modify your running total.
    Open the running total you created -> Under Evaluate click the X+2 to add a formula -> insert this logic:
    not isnull({wo.opendate})
    This should then only count the wo that are open.
    I hope this helps,
    Regards,
    Zack H.

  • Counting Column in Table

    good day all,
    JSC provides wonderful sorting features out of the box for tables and these allow my users to look at a dataset from many different angles without making a new query.
    however my users are very interested in placings so if they sort by a particular column and focus on a row, they want to know what position is that row according to the current sort.
    in reality i simply want a column that has counting numbers 1 to x that remain that way regardless of what column the data is sorted by.
    i know this may be a bit confusing, but please let me know if you have any ideas as to how i can accomplish this. also if this is not clear please let me know and i will clarify anything that you don't understand.
    thank you.
    take care
    kroikie

    haha,you can give a varible in session bean

Maybe you are looking for