Archive for month: February, 2009

Using Dynamic Values in the PIVOT Operator

21 February, 2009 (10:20) | T-SQL | By: Mark V

I recently worked on a report for a client in which a date input parameter was used to determine the end dates of the previous four calendar quarters. Each time the report ran, it returned data for all four of those quarters. I ended up using PIVOT in the course of the stored procedure for […]

Things You Know Now…

20 February, 2009 (21:59) | T-SQL | By: Mark V

I was tagged by Jason Strate for cool blog chain. I guess I’m it now.    Get the Last Date in a Calendar Quarter I needed to accurately calculate the end dates for the four most recently completed calendar quarters prior to the date provided. I found this snippet online and thought it was a […]

The Coolness of the T-SQL NTILE Function

17 February, 2009 (21:47) | T-SQL | By: Mark V

I had need of calculating metrics across an industry and then returning the quartile in which each company scored. So, i wrote up a function that took in the MinValue, MaxValue, and CompanyMetricValue as inputs and returned the quartile for the Company. Great. Then, when askingĀ  someone else about this using this new function, the […]