March 30, 2011 archive

Columns to Rows

I was doing a code review of a view that would be going into production. The view’s SELECT statement was defined as: SELECT status.STATUS_ID, status.ITEM_ID, status.REQUEST_FLAG, status.ITEM_CODE, status.PLAN_CODE, status.STATUS_CODE FROM ( SELECT STATUS_ID STATUS_ID, ITEM_ID ITEM_ID, REQUEST_FLAG REQUEST_FLAG, ITEM_CODE ITEM_CODE, PLAN_CODE PLAN_CODE, STATUS_CODE_1 STATUS_CODE FROM SCHEMA1.STATUS_TABLE UNION ALL SELECT STATUS_ID STATUS_ID, ITEM_ID ITEM_ID, REQUEST_FLAG REQUEST_FLAG, …

Continue reading