I've just come across an interesting SQL question here on CodeRanch. How to generate date ranges in SQL, given any input date. The question didn't specify the SQL dialect, so let's choose Oracle SQL, which features the awesome CONNECT BY clause. The requirements specify that given any input date: Date ranges span 12 months The … Continue reading How to Generate Date Ranges in Oracle SQL
Tag: function
Simulation of TRUNC() in Derby
Derby is missing out a lot of functions from the set of functions that other databases usually provide. One example is the TRUNC(value, decimals) function. According to the Wikipedia, truncation can be achieved as such: -- trunc(x, n) CASE WHEN x > 0 THEN floor(power(10, n) * x) / power(10, n) ELSE ceil(power(10, n) * … Continue reading Simulation of TRUNC() in Derby