Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to construct a hard one
Message
 
 
À
03/02/2007 22:41:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01192180
Message ID:
01192185
Vues:
14
Try
SELECT * FROM Invoices inv
	WHERE EXISTS ( SELECT * FROM Daterange dr 
				WHERE dr.Category = inv.Category
					AND inv.Deliverydate BETWEEN dr.DateBegin AND dr.DateEnd
					AND FlockNum BETWEEN Flbegin AND Flend)
>
>How would one construct the SQL for the following. Consider the two tables:
>
>
>Table: INVOICES
>
>  Category        Delivery date      Quantity    price
>  FFPP            01/10/2006         1.0000      59.0000
>  FFPP            01/10/2006         1.0000      59.0000
>  FFPP            10/20/2005         1.0000      12.2500
>  FFPP            10/20/2005         1.0000      69.2200
>  Commercial      10/20/2005         4.0000       7.5000
>  FFPP            10/20/2005         2.0000       6.2500
>  Organic         10/20/2005         1.0000      10.6200
>
>Table:  DATERANGE
>  Category        Flock Num   Date Begin Date End
>  FFPP            2064        01/25/2006 8/24/2006
>  FFPP            2065        08/25/2006 10/25/2006
>  FFPP            2066        10/26/2006 12/31/2006
>  Organic         2064        02/25/2006 6/30/2006
>  Organic         2065        07/01/2006 08/31/2006
>  Organic         2066        09/01/2006 10/30/2006
>  Commercial      2064        03/25/2006 9/20/2006
>  Commercial      2065        09/21/2006 11/30/2006
>  Commercial      2066        12/01/2006 01/31/2007
>
>
>The pseudocode for the SQL
>
>Flbegin = '2065'
>flend = '2066'
>
>Select only the records in table INVOICES where delivery date is within the range specified by table DATERANGE, The range is where the flock number is within flbegin and flend. However, only use those records in DATERANGE where the category field matches.
>
>Thanks,
>
>Yossi
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform