Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Week Number of the Year Question
I'm very sorry if this has been hashed here several times before. I
honestly have been searching the web and newsgroups for hours today for
answers.
I'm somewhat new to SQL (about 8 short months under my belt) and my learning has been limited to several SQL tutorials on the web and several "Learn SQL in XX Hours" books. I've been requested to create a query for a report that counts the number of patient visits to a list of providers throughout a year but the visits are to be totaled by the weeks of the years.
Example:
Week 1
Dr Jones 8 visits
Dr Smith 4 visits
Week 2
Dr Jones 63 visits
Dr Smith 74 visits
...
...
I've found that I can use TO_CHAR and WI or WW (WI works better for me) to find the week, I'm just having trouble figuring out how to mix that information in with my query (told you I was fairly new with this).
My query is simply:
select provider, patientid, visitdate, visittype
from visit_table
I'm probably making this harder than it is, but for some reason I'm thinking I have to do a sub-query in here to get the query to count visits by weeknumber for each provider, but I'm just not getting it.
Any help would be very appreciated
Thank you!
Greg
Received on Sun Nov 20 2005 - 23:46:57 CST