Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sequencing on date- time
Message
 
 
To
01/01/2017 12:05:02
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01646191
Message ID:
01646243
Views:
34
Create VIEW Test as 

with cte as (select *, count(*) over (partition by driver, location, datepart(weekday, pickupdate), pickuptime) as cntTimesPerDay from DeliveryTable),
cte2 as (select *, row_number() over (partition by driver, location, datepart(weekday, pickupdate) order by cntTimesPerDay DESC) as Rn from cte)
select * from cte2 where Rn = 1 -- rows with most common times per day per driver/location
>Naomi...
>I've been trying to put this into a view, and can't find any way to do it.
>Can it be done?

Sure, try the syntax above.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform