~/devreads

#pivot

3 posts

18 Jan 2016

lukaseder 1 min read

I’ve recently encountered a very interesting question on Stack Overflow by an unnamed user. The question was about generating a table of the following form in Oracle, using a table valued function: Description COUNT ------------------- TEST1 10 TEST2 15 TEST3 25 TEST4 50 The logic that should be implemented for the COUNT column is the … Continue reading Impress Your…

sqloraclepivotsql serverunpivot

26 Feb 2015

lukaseder 1 min read

This can happen ever so easily. You adapt a table by adding a new column: You go on, implementing your business logic – absolutely no problem. But then, later on (perhaps in production), some batch job fails because it makes some strong assumptions about data types. Namely, it assumes that the two tables payments and … Continue reading How to…

sqlcase expressionfilter clauseoraclepivot

5 Aug 2014

lukaseder 1 min read

Every once in a while, we run into these rare SQL issues where we’d like to do something that seems out of the ordinary. One of these things is pivoting rows to columns. A recent question on Stack Overflow by Valiante asked for precisely this. Going from this table: +------+------------+----------------+-------------------+ | dnId | propNameId | … Continue reading Are You…

sqloraclepivotsql server