INSERT INTO PRODUCT_ROW(PRODUCT_ROW_ID,PRODUCT_ID,PRODUCT_DESC,Quarter_ID, Quarter_Amt) Quarter_Amt NUMBER(13,2) DEFAULT 0 NOT NULL,ĬONSTRAINT PK_PRODUCT_ROW PRIMARY KEY(PRODUCT_ROW_ID) INSERT INTO PRODUCT_COL (PRODUCT_ID,PRODUCT_DESC,Q1_SALES_AMT,Q2_SALES_AMT,Q3_SALES_AMT,Q4_SALES_AMT) Q4_SALES_AMT NUMBER(13,2) DEFAULT 0 NOT NULL,ĬONSTRAINT PK_PRODUCT_COL PRIMARY KEY(PRODUCT_ROW_ID,PRODUCT_ID) Q3_SALES_AMT NUMBER(13,2) DEFAULT 0 NOT NULL, Q2_SALES_AMT NUMBER(13,2) DEFAULT 0 NOT NULL, Q1_SALES_AMT NUMBER(13,2) DEFAULT 0 NOT NULL, Create two tables to demonstrate the basic PIVOT and UNPIVOT functionality and populate it with data. We are using the same examples as used in above mentioned blog post but for easier readability we are mentioning it here again. We will cover the basic flavor of PIVOT and UNPIVOT operators in the blog post. In 11g Oracle introduced these two operators to convert rows to columns and vice versa. We have also covered the traditional way of pivoting the data for prior version of SQL Server and for other databases in one of our previous blog post. You can read more on that in our whitepaper. to convert rows into columns and columns into rows. Microsoft introduced the PIVOT and UNPIVOT operator in SQL Server 2005 to generate cross tab reports i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |