SQL queries complex data and displays statements
SQL queries complex data and displays statements
SQL queries complex data and displays statements
// Method 2
Select name, content, imgurl, synois from (
Select name, content, imgurl, synopsis, row_number () over (partition by name order by content) as rn
From table1
) T where t. rn = 1
// Method 2
If object_id ('[tb]') is not null drop table [tb]
Create table [tb] ([name] varchar (1), [content] varchar (5), [imgurl] varchar (5), [synopsis] varchar (6 ))
Insert [tb]
Select 'A', 'different 1', 'different 1', 'can be left blank 'Union all
Select 'A', 'different 2', 'different 2', 'can be left blank 'Union all
Select 'A', 'different 3', 'different 3', 'can be left blank 'Union all
Select 'B', 'different 4', 'different 4', 'can be left blank 'Union all
Select 'B', 'different 5', 'different 5', 'can be left blank 'Union all
Select 'C', 'different 6', 'different 6', 'Do not fill in'
Select * from [tb]
With tt
As (
Select id = row_number () over (partition by name order by name), * from tb)
Select [name], [content], imgurl, synopsis from tt where id = 1