Such as the appended drawings of the duplicate number 1
How to write a statement
CodePudding user response:
The test data-If not object_id (N 'Tempdb for.. # T ') is null
Drop table # T
Go
The Create table # T (int [row], [zc] nvarchar (21), (bs) int)
Insert # T
Select 1, N 'a', 111 union all
Select 2, N 'a', 111 union all
Select 3, N 'a', 112 union all
Select 4, N 'b', 112
Go
- the end of the test data
The SELECT zc,
COUNT (1) - 1 AS the repetitions
The FROM
(SELECT DISTINCT zc, bs FROM # T) T
GROUP BY zc.