Tag Archives: TSQL

T-SQL Pivots a Table

This post demos how to pivot a table using both the Pivot function and a home made approach. The code can be found from GIST. Problem An OrderItem table contains orderId, itemName and qty as its columns. Now we want … Continue reading

Posted in Database | Tagged , , | 1 Comment

TSQL’s Equivalent to Create New Query Based on Previous Query Result

I have a table called PRICE with two columns, unitPrice and resellerId. From my application, I use the following code (pseudo) to query the unitPrice for a given reseller. Basically I use the unitPrice if the resellerId presents in the … Continue reading

Posted in Database | Tagged , | Leave a comment