Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hello,
how is it possible to get the distinct count?
please see screen-shot which shows the data and what I would like the result to show as
Thank you
DROP TABLE IF EXISTS #temp
CREATE TABLE #temp
(
ID int,
sec nvarchar(5)
)
insert into #Temp (ID,sec) VALUES (999,'XXX')
insert into #Temp (ID,sec) VALUES (999,'XXX')
insert into #Temp (ID,sec) VALUES (888,'XXX')
insert into #Temp (ID,sec) VALUES (888,'XXX')
insert into #Temp (ID,sec) VALUES (432,'XXX')
insert into #Temp (ID,sec) VALUES (432,'XXX')
insert into #Temp (ID,sec) VALUES (678,'XXX')
insert into #Temp (ID,sec) VALUES (678,'XXX')
SELECT ID,
sec,
COUNT(distinct sec)
FROM #temp
GROUP BY ID,
sec
Hi @arkiboys
It is a easy question.
SELECT ID ,MAX(sec),COUNT(*) FROM TABLE GROUP BY ID
Best Regard,
Isabella