Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Remove duplicates with in 10 min
--Sql Server 2014 Express Edition --Batches are separated by 'go' create Table Datetimetable ( ID int, Name varchar(30) , DateTime1 datetime ) Insert into Datetimetable(ID,Name,DateTime1)values(1,'Joe','2017-03-01 11:33:13'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'Joe','2017-03-01 11:33:14'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'Joe','2017-03-01 11:33:15'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'Joe','2017-03-01 11:55:30'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'John','2017-03-15 08:55:48'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'John','2017-03-15 08:55:49'); Insert into Datetimetable(ID,Name,DateTime1)values(1,'John','2017-03-15 10:15:40'); with cte as ( select *,row_number() over( partition by ( CAST(CONVERT(CHAR(16), [DateTime1],113) AS datetime)) order by [Name]) as rn from Datetimetable ) select * from cte where rn=1 select *, row_number() over ( partition by (CAST(convert(CHAR(16),DateTime1,113)AS datetime)) order by Name) from Datetimetable SELECT A.ID,A.NAME,A.[DATETIME1] FROM (SELECT *,ROW_NUMBER() OVER( PARTITION BY ( CAST(CONVERT(CHAR(16), [DATETIME1],113) AS DATETIME)) ORDER BY [NAME]) AS RN FROM Datetimetable )A WHERE RN=1 ORDER BY ID
run
|
edit
|
history
|
help
2
Display Multiple Rows as a single Line
Finding Row Wise Max Value From Table
test22
Crea, confirma y despliega tablas
https://www.hsbc.co.in/ways-to-bank/online-banking/9247/
BC160401693
Exam_Final
SQL
Rno 37 boat
TSql - Unroll inventory transactions and compute daily average