Multiple rows and columns in SQL multi-row and multiple column tips

Source: Internet
Author: User

---restore content starts---

[

This afternoon to accept an emergency small task, is a set of record statistics, the chess game player's two records in a row of the display, into the database after the first thought is the row to the column, but at the beginning felt wrong, and later wrote half really wrong, later on the Internet query for half a day more than a row of rows and more columns, Found to write algorithms and write functions, see the real headache, do not want to be so troublesome. So he suddenly brainwave, flashed a small idea, immediately implemented, is to add all the records preceded by an identity column num (row_number () function), and then use case to determine the parity line in the display, it is OK. Select Row_number () over (order by Drawid) as num,* from QPTreasureDB.dbo.RecordDrawScore wheredrawid in (select Drawid from QPTreasureDB.dbo.RecordDrawInfo where kindid= ' 400 '). Don't know if it's a little trick, share it with everyone.

Pasting

---restore content ends---

Multiple rows and columns in SQL multi-row and multiple column tips

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.