Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Yan_1st_wall
--Sql Server 2014 Express Edition --Batches are separated by 'go' declare @t table ( Id int , section int, time date, value int ); insert into @t values ( 1 , 1 , '2014-01-01', 2), ( 2 , 1 , '2014-01-01', 3), ( 3 , 2 , '2014-01-01', 1), ( 4 , 2 , '2014-01-01', 1), ( 5 , 2 , '2014-01-01', 5), ( 6 , 1 , '2014-02-02', 1), ( 7 , 1 , '2014-02-02', 6), ( 8 , 1 , '2014-02-02', 7), ( 9 , 1 , '2014-02-02', 1), ( 10 , 2 , '2014-02-02', 1), ( 11 , 1 , '2014-03-11', 2), ( 12 , 2 , '2014-03-11', 7), ( 13 , 3 , '2014-03-11', 1), ( 14 , 3 , '2014-03-11', 2), ( 15 , 3 , '2014-03-11', 3); select * from @t; Select Id, time, section, value, ranks from (select Id, time, section, value, Rank() over (partition by time order by value desc) as ranks From @t) T Where ranks < 3;
run
|
edit
|
history
|
help
0
Comercio
QLDT_TUAN 7
Demo
Elena-Tests
identity
Get all dates between two given dates
Libros
query
sum vs count with multiple options in group by clause
Running Total