Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple wheres with dates please

Status
Not open for further replies.

jtsaint

IS-IT--Management
Feb 10, 2003
3
GB
I have the following table:

POINTS
______
pid
junior
clubpoints
countypoints
junioropenpoints
date


I wish to show a sum for club, county and juniot points grouped by junior. This is fine but now I need to show, in the same table the sum of club county and junior open points before the first of this month and the sum of club county and junior open points after the first of this month.

Any help much appreciated! - I might have to do this in java and manually sort it but I would have prefered an SQL solution.
 
Code:
select junior, sum(clubpoints),sum(countyPoints),
sum(junioropenpoints),'Before' from points
where &quot;DATE&quot; < date '2003-04-01'
group by junior
union 
select junior, sum(clubpoints),sum(countyPoints),
sum(junioropenpoints),'After' from points
where &quot;DATE&quot; >= date '2003-04-01'
group by junior
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top