mrccopeland
Programmer
Hello All,
I'm having a bit of a difficult time here. I have a query that I can run for a single day and it produces the correct output for the situation. The query goes as follows:
SELECT DATEPART(mm, entrydate) AS tranmonth,
DATEPART(dd, entrydate) AS tranday,
DATEPART(yyyy, entrydate) AS tranyear,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE (ENTRYDATE between '07-16-2003 10:00:00' AND '07-16-2003 11:59:00') OR
(ENTRYDATE between '07-16-2003 14:00:00' AND '07-16-2003 15:59:00')) AS Peak,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 07:00:00' AND
ENTRYDATE <= '07-16-2003 18:59:59') AS BusinessHours,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 19:00:00' AND
ENTRYDATE <= '07-17-2003 06:59:59') AS OffHours
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 00:00:00' AND
ENTRYDATE <= '07-17-2003 06:59:59'
GROUP BY DATEPART(mm, entrydate), DATEPART(dd, entrydate), DATEPART(yyyy, entrydate)
ORDER BY DATEPART(mm, entrydate), DATEPART(dd, entrydate), DATEPART(yyyy, entrydate)
It's used to count the number of transactions for a given day during some specific hours. The output follows as such
7 16 2003 6820 13913 0
Where my problem comes in is being able to run this for multiple days at a given time. Say I want to run this for the month of July. I don't want just one record for july with a total count, what I'm looking for is a record for each day in July with the counts for that day. Something like:
7 1 2003 6788 10999 12
7 2 2003 3248 12000 0
7 3 2003 0 0 0
7 4 2003 10 19 0
.....
7 31 2003 8723 9823 14
Any suggestions?
I'm having a bit of a difficult time here. I have a query that I can run for a single day and it produces the correct output for the situation. The query goes as follows:
SELECT DATEPART(mm, entrydate) AS tranmonth,
DATEPART(dd, entrydate) AS tranday,
DATEPART(yyyy, entrydate) AS tranyear,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE (ENTRYDATE between '07-16-2003 10:00:00' AND '07-16-2003 11:59:00') OR
(ENTRYDATE between '07-16-2003 14:00:00' AND '07-16-2003 15:59:00')) AS Peak,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 07:00:00' AND
ENTRYDATE <= '07-16-2003 18:59:59') AS BusinessHours,
(SELECT COUNT(*)
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 19:00:00' AND
ENTRYDATE <= '07-17-2003 06:59:59') AS OffHours
FROM TRANSERVICE
WHERE ENTRYDATE >= '07-16-2003 00:00:00' AND
ENTRYDATE <= '07-17-2003 06:59:59'
GROUP BY DATEPART(mm, entrydate), DATEPART(dd, entrydate), DATEPART(yyyy, entrydate)
ORDER BY DATEPART(mm, entrydate), DATEPART(dd, entrydate), DATEPART(yyyy, entrydate)
It's used to count the number of transactions for a given day during some specific hours. The output follows as such
7 16 2003 6820 13913 0
Where my problem comes in is being able to run this for multiple days at a given time. Say I want to run this for the month of July. I don't want just one record for july with a total count, what I'm looking for is a record for each day in July with the counts for that day. Something like:
7 1 2003 6788 10999 12
7 2 2003 3248 12000 0
7 3 2003 0 0 0
7 4 2003 10 19 0
.....
7 31 2003 8723 9823 14
Any suggestions?