Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dividing runs by time stamp
CREATE TABLE Table1 ([strvalue] varchar(1), [eventtime] varchar(4)) ; INSERT INTO Table1 ([strvalue], [eventtime]) VALUES ('A', '1:00'), ('A', '1:05'), ('B', '1:10'), ('C', '1:15'), ('A', '1:20'), ('A', '1:25'), ('A', '1:30') ; SELECT max(eventtime) as maxTime , min(eventtime) as minTime , strvalue as PartNum FROM (SELECT * , ROW_NUMBER() OVER (ORDER BY eventtime desc) - ROW_NUMBER() OVER (PARTITION BY strvalue ORDER BY eventtime desc) as grouping FROM Table1) as t1 GROUP BY t1.grouping, t1.strvalue ORDER BY min(eventtime) desc
run
|
edit
|
history
|
help
0
MSSQL NVARCHAR to INT conversions
bc160402152
Data row generator (good performance, w/o recursive CTE)
Common Table Expression
M0413045.sql
HOTEL
c12part2
SQL SERVER 2012 how to split records in a column separated by delimiter
Factorial
table emp