3 ms·
A common grouping needed by sysadmins is to group by 5 minute intervals. That query may be more likely to trip up a junior DBA than most of these. Could be use
by Terretta 13y ago
A common grouping needed by sysadmins is to group by 5 minute intervals. That query may be more likely to trip up a junior DBA than most of these. Could be useful to add.
Example use case: http://www.techtalkz.com/microsoft-sql-server/170861-grouping-sql-output-5-minute-intervals.html http://www.techtalkz.com/microsoft-sql-server/170861-groupin...
- umsm 13y agoDo you happen to know the most elegant solution to this problem? Convert the date to seconds since date X (or unix timestamp / 60) and divide by the number of mins you need and convert to int.
- pjungwir 13y agoPostgres has `EXTRACT(EPOCH FROM date_col)`, which might not be where you'd think to find that functionality.
- jacques_chester 13y agoNever use raw numbers to represent slices of time, there's just too many corner cases that can throw your calculations off. Use the INTERVAL data type, it handles the logic properly.
- akane 13y agoGood suggestion!