Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OK, another one
Message
 
 
À
20/01/2009 12:16:48
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01374859
Message ID:
01375534
Vues:
26
>Here's the one I've used...
>
>
>SELECT TimeSheets.EmployeeID, Month(WorkDate) as MonthPay , YEAR(WorkDate) AS YearPay,
>   SUM(TimeSheets.HoursWorked * WorkerRates.HourlyRate)  AS LaborDollars
>        FROM TimeSheets
>              JOIN WorkerRates ON WorkerRates.EmployeeID = TimeSheets.EmployeeID 
>
>                  WHERE WorkerRates.RateEffectiveDate = 
>                        (SELECT MAX(RateEffectiveDate) FROM WorkerRates RatesTemp
>                                      WHERE RateEffectiveDate <= WorkDate AND 
>                                                     RateAddedDate <= WorkDate AND 
>                                                   RatesTemp.EmployeeID = TimeSheets.EmployeeID)
>    GROUP BY TimeSheets.EmployeeID, Month(WorkDate),YEAR(WorkDate)
>
>
>Obviously, you could use a CTE as well.
>
>Our execution plans are different....yours is interesting....obvoiusly, more than one way to do it.
>
>Later tonight I'll try to post the execution plans.
>
>Thanks for participating...

I see, this seems now like a more obvious and direct approach, I wonder why I didn't think that straight? :)

Thanks.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform