SQL statement and SQL

Source: Internet
Author: User

SQL statement and SQL

As a C # Language developer, it is difficult to escape from dealing with SQLSERVER. Although we are developers, what I want to say is, database operations should be reviewed from time to time. The following is an interesting SQL question I have seen. I will share it with you!

 

Question: there is a table Named department in my tepk database, which has only one field name and a total of four records, which are a, B, c, and d, corresponding to four teams, now we have four matches, and only one match is required between two or two. Now, use an SQL statement to display all possible combinations of matches.

 

Solution:

1. Check all the conditions that meet the requirements first. There are 16 types in total.

Result:

2. Filter

The final result is: 6 Types

 

The process now seems very simple, right? But at that time it was really hard to think about writing. Hahaha. Thank you!

 

Related Article

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.