add remove language chart show hidden hide
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
(No column name)
Microsoft SQL Server 2017 (RTM-CU21) (KB4557397) - 14.0.3335.7 (X64)
 Jun 12 2020 20:39:00
 Copyright (C) 2017 Microsoft Corporation
 Express Edition (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)
8 rows affected
Serviceid Date User_id
20 2018-01-02 40709217
20 2018-01-02 40709217
40 2018-01-02 40709217
40 2020-01-02 40709217
50 2021-01-02 40709217
984 2018-03-22 18246539
269 2018-03-22 18246539
666 2018-04-01 18246539
Serviceid Date User_id earliest_order latest_order rank_priority
984 2018-03-22 18246539 1 3 1
269 2018-03-22 18246539 1 2 2
666 2018-04-01 18246539 2 1 1
40 2018-01-02 40709217 1 5 1
20 2018-01-02 40709217 1 3 2
20 2018-01-02 40709217 1 4 3
40 2020-01-02 40709217 2 2 1
50 2021-01-02 40709217 3 1 1
User_id FirstServiceid SecondServiceid FirstServiceDate SecondServiceDate LastServiceid LastServiceDate TotalService
40709217 40 40 2018-01-02 2020-01-02 50 2021-01-02 5
18246539 984 666 2018-03-22 2018-04-01 666 2018-04-01 3
Warning: Null value is eliminated by an aggregate or other SET operation.