Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sequencing on date- time
Message
 
 
À
01/01/2017 12:05:02
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01646191
Message ID:
01646243
Vues:
35
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform