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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with query

Status
Not open for further replies.

orna

Programmer
Apr 2, 2002
314
IL
Hi
I have 2 fields in a table: StartDate, EndDate
and need to make a chart:
count records where the diff between the dates:
0-10 days
11-20 days
.
.
>365 days

How can i build the crosstab query?
TIA

 
A Starting point:
SELECT Int((EndDate-StartDate)/10) As Decade, Count(*)
FROM YourTable
WHERE EndDate<=StartDate+369
GROUP BY Int((EndDate-StartDate)/10)
UNION SELECT 99, Count(*)
FROM YourTable
WHERE EndDate>StartDate+369

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PH

I didnt quite understand what did you mean but you gave
me the right direction and i manage to get it work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top