SELECT
[reportableresultid]
,[samplecode]
,[testprepetitioncode]
,[testcode]
,[parametercode]
,[reportableresultcode]
,[iscalculated]
,[createdonutc]
FROM (SELECT [reportableresultid]
,[samplecode]
,[testprepetitioncode]
,[testcode]
,[parametercode]
,[reportableresultcode]
,[iscalculated]
,[createdonutc]
,row_number() Over(partition by reportableresultcode, iscalculated order by [createdonutc] desc) rn
FROM [dbo].[yourtablename]
) t
where rn>1
Need SQL Query for unique constraint 2 columns take all Min date except Max Date
Indudhar Gowda
426
Reputation points
Need SQL Query for unique constraint 2 columns take all Min date and do not take Max Date.
In the Above Screen Shot.....Need SQL Query for [reportableresultcode] and [iscalculated] are unique constraint 2 columns, Take duplicates but dont take MAX Date.
Insert Duplicate Row's in TempTable.
I have attached the Excel sheet ..
Azure SQL Database
Azure SQL Database
An Azure relational database service.
6,326 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
Developer technologies Transact-SQL
4,707 questions
SQL Server Other
14,494 questions
Accepted answer
-
Jingyang Li 5,896 Reputation points Volunteer Moderator
2022-06-02T15:38:13.73+00:00