Home > database >  For a single SQL
For a single SQL

Time:10-03

Every year has a set of indicators, the same also have different, now you need to put the same indicators found out every year, how do you write SQL

CodePudding user response:

Under the details,,,

CodePudding user response:

Suggest you list your table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,

CodePudding user response:

Give point data + clear requirements, otherwise not laid hands on him

CodePudding user response:

The original poster is the need to extract the duplicate records? I did this
SELECT DISTINCT the column names of the (need to) FROM (your data table name)

CodePudding user response:

The use of having a count (the same indicators) & gt; 1

CodePudding user response:

Logic is probably check duplicate data, according to the target group, on condition that the number & gt; 1

Select year, indicators from the table where indicators in (select from table group by indicators having count (indicators) & gt; 1)

CodePudding user response:

Check duplicate data, the first to use distinct, also can be used to having a count (indicators) & gt; 1
  • Related