Still today I occasionally work with people who aren't familiar with some features I almost take for granted.
Today's little observation was with ROLLUP - a function used in
group by
queries to provide sub-totals.I was looking at log frequency by month, and I also needed to consider grand total, so consider:
Rollup folks! |
select count(*), trunc(view_date,'mm') from activity_log group by rollup(trunc(view_date,'mm')) order by 2 desc nulls last
You'll also want to check out single row functions such as GROUPING.
Go nuts.
No comments:
Post a Comment