SQL Programming Questions-----1

Source: Internet
Author: User

First, the topic gives the database table

Require that SQL statements be written to form the following table

Workaround:

SELECT t1. RQ,T1, T2. Negative from//T1 and T2 are the names of the new forms of their own lives

(Select Rq,count (*) as wins//as means that the output is named "Win"
From TestTable
WHERE shengfu= ' wins '
GROUP by Rq) T1

INNER JOIN//inner jion ... On linked list query

(SELECT rq,count (*) as negative
From TestTable
WHERE shengfu= ' negative '
GROUP by Rq) T2

on T1. Rq=t2. RQ//on After the presentation of the new table T1 and T2 have a common column RQ supplement: If only the number of WINS is less than the negative date, then add and T1 directly here. Win <t2. Negative
ORDER by T1. Rq DESC//desc, descending order, ASC ascending

Add: And T1. Win <t2. Negative

SQL Programming Questions-----1

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.