A complex SQL statement

Source: Internet
Author: User
1   Select C. * , Sum (T. Num) As Num, B. Num As Total From Np_wenjuan_choice As  C  2   Left   Join  (  3   Select Content,Count (ID) As  Num  4   From Np_wenjuan_answer As  A  5   Where Question_id =   8  6   Group   By  Content  7 )As T On T. Content Like Concat ( '  %  ' , C. Index , '  %  '  )  8   Left   Join  (  9  Select Question_id, Count (ID) As  Num  10   From  Np_wenjuan_answer  11   Where Question_id =   8  12   Group   By  Question_id  13 ) As B On B. question_id =  C. question_id  14   Where C. question_id =   8  15   Group   By  Title  16   Order   By C.Index 

 

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.