SQL statement exercise instance-10 SQL Server row-to-column performance tests

Source: Internet
Author: User
During database design, sometimes attribute record values belonging to the same person are stored in multiple records for the purpose of data standardization, you want to merge multiple attribute data into one row for display. This is a row-to-column conversion. For example, the score table. 1. method 1 (Versions later than SQL2000) -- a total of 1.2 million records SE

During database design, sometimes attribute record values belonging to the same person are stored in multiple records for the purpose of data standardization, you want to merge multiple attribute data into one row for display. This is a row-to-column conversion. For example, the score table. 1. method 1 (SQL 2000 and later versions) -- a total of 1.2 million records SE

During database design, the US space sometimes uses multiple records to store the attribute record values of the same person for the purpose of data standardization, when displaying, you want to combine multiple attribute data into one row for display. This is a row-to-column conversion for the Hong Kong virtual host.

For example, the score table.

1. method 1 (SQL 2000 and later versions)

-- SELECT wbook_no, MAX (case when [COP_G_NO] = '000000' then ar end) "1.2 million ", MAX (case when [COP_G_NO] = '000000' then ar end) "50165814", MAX (case when [COP_G_NO] = '000000' then ar end) "10221553" FROM (SELECT [COP_G_NO], wbook_no, SUM (G_QTY * decl_Price) ARFROM WBK_PDE_LISTWHERE [COP_G_NO] in ('123456', '123456', '123456 ') group by [COP_G_NO], wbook_no) agroup by wbook_no

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.