SQL query to find business days of the month

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
I need to run a query against the ACTIVE table to gather data group by each business day of the month.

So if there are 21 business days in the month, I will have 21 rows of data.
If there are 19 business days I will have 19 rows of data.

I will be doing a COUNT of data from the ACTIVE table and returning that count in each of the rows which is a business day.

Does that make sense? These things are so hard to describe in text...
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Actually I think I figured out a way I can "cheat" at this.
Since entries to ACTIVE are only going to be entered on business days already, I think I can get away with just grouping by ACTIVE. TRANS_DATE

GROUP BY ACTIVE.TRANS_DATE
ORDER BY ACTIVE.TRANS_DATE

For the month of October, it seems to be just fine:

TRANS_DATE
2011-10-03
2011-10-04
2011-10-05
2011-10-06
2011-10-07
2011-10-10
2011-10-11
2011-10-12
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
That will work unless you have a business day where there are no rows, then it will not return a row, where you probably want to to return 0.
 

Homerboy

Lifer
Mar 1, 2000
30,856
4,974
126
Correct, but if there was a business day that didn't have a row, we'd have some major issues around here

I did just realize a major problem though. Technically people work on Saturdays and those numbers are to be lumped into Friday's together (though we do not count Saturday as a "work day" so there is only 21 work days in October, not 26)

Long story short, I can't figure out a way to automatically add Friday and Saturday together since I'm just grouping by DATE.
 

Jeraden

Platinum Member
Oct 9, 1999
2,518
1
76
Override the trans_date on the saturday row, to make it look like its friday. Not sure of non-oracle syntax, but if I was doing it in Oracle..

instead of:
group by active.trans_date

I'd do:
group by decode(to_char(active.trans_date,'Day'),'Saturday',active.trans_date - 1,active.trans_date)
so basically on saturday, use the day before, if not saturday, just use the normal date

and use that in the order by and select clause as well instead of trans_date directly. I'm sure there is similar command for other databases.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |