Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query #2 - MySQL and MS-SQL
Message
De
28/02/2008 01:34:33
Walter Meester
HoogkarspelPays-Bas
 
 
À
27/02/2008 13:56:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01296743
Message ID:
01297282
Vues:
28
Kevin,

>
>; WITH DateCTE (WeekEnding)  AS
>     -- Anchor query to get the first date
>     (SELECT @StartDate AS WeekEnding
>       UNION ALL
>          -- Recursive query to grab the rest of the dates
>          SELECT DateAdd(day,7,WeekEnding) AS WeekEnding FROM DateCTE
>             WHERE WeekEnding < @EndDate ),
>
>       -- 2nd CTE to grab the list of Vendors
>       VendorListCTE (VendorID)   AS
>         (SELECT VendorID FROM Purchasing.PurchaseOrderHeader
>             GROUP BY VendorID)
>
Thanks in providing a possible implementation using recursivism.

However it suprises me a bit that you would prefer this over the simple approach of using a temp table. I would not consider this alternative if it were only for the reason that it is it is less readable of what is going on (A common problem with CTE's anyways).

OTOH, it is a good example of how to impress other people not familiar with CTEs and implementing a simple problem in a difficult way. (TEST: give the two solutions to any SQL developer and ask them to figure out what is going on).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform