SQL Statement Memo: non-int type row to column

Source: Internet
Author: User

For example, the result is a varchar type, need row to column, Baidu to is the operation of the type int, toss a long time, just the whole out, here to prepare a forget, but it is said that the performance is worrying, so here also see the big God pointing guidance, where can improve, thank you.
1 --does not apply to fields that have type text, ntext, etc. that cannot perform distinct operations2 SELECT DISTINCTA.code,3(SELECTResult fromTest bWHEREA.code=B.code andB.type=1) as'First Instance',4(SELECTResult fromTest bWHEREA.code=B.code andB.type=2) as'Review'5  fromTest A
1 SelectA.code,a.result'First Instance', B.result'Review'  from 2(SELECTCode,result fromTestWHEREType=1) A3  Inner Join(SELECTCode,result fromTestWHEREType=2) b onA.code=B.code

SQL Statement Memo: non-int type row to column

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.