Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need advice on SQL
Message
De
17/09/2006 18:20:37
 
 
À
17/09/2006 18:03:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01154440
Message ID:
01154513
Vues:
9
>sorry I have not looked well.
>
>try ( if VFP support it ):
>
>SELECT Program.Numero,Program.Active,Program.Title,Program.Notes_E,Program.Notes_F,Program.NoMaster,;
> Master.FirstName,Master.LastName,MasterType.Title_E AS MasterType_E,MasterType.Title_F AS MasterType_F,Video.Url,Video.Numero AS PrimaryKey;
> FROM Program;
> INNER JOIN Master ON Program.NoMaster=Master.Numero;
> INNER JOIN MasterType ON Master.NoMasterT=MasterType.Numero;
> INNER JOIN Video ON Program.Numero=Video.NoProgram;
> INNER JOIN InvoiceI ON Video.Numero=InvoiceI.NoVideo;
> INNER JOIN Invoice ON InvoiceI.NoInvoice=Invoice.Numero;
> WHERE Program.Active AND Invoice.AddUser=1;
> AND Video.Numero=(SELECT MIN(V.Numero) FROM Video V JOIN InvoiceI I ON V.Numero=I.NoVideo WHERE V.NoProgram=Video.NoProgram);
> ORDER BY Program.Title
>
>but it can to be not sufficient.
>
>
>SELECT Program.Numero,Program.Active,Program.Title,Program.Notes_E,Program.Notes_F,Program.NoMaster,;
> Master.FirstName,Master.LastName,MasterType.Title_E AS MasterType_E,MasterType.Title_F AS MasterType_F,Video.Url,Video.Numero AS PrimaryKey;
> FROM Program;
> INNER JOIN Master ON Program.NoMaster=Master.Numero;
> INNER JOIN MasterType ON Master.NoMasterT=MasterType.Numero;
> INNER JOIN Video ON Program.Numero=Video.NoProgram;
> INNER JOIN InvoiceI ON Video.Numero=InvoiceI.NoVideo;
> INNER JOIN Invoice ON InvoiceI.NoInvoice=Invoice.Numero;
> WHERE Program.Active AND Invoice.AddUser=1;
> AND Video.Numero=(SELECT MIN(V.Numero) FROM Video V JOIN InvoiceI I ON V.Numero=I.NoVideo;
> JOIN  Invoice ON I.NoInvoice=Invoice.Numero AND Invoice.AddUser=1;
> WHERE V.NoProgram=Video.NoProgram);
> ORDER BY Program.Title
>
>
>
>It is better probably a solution in two steps.

Both SQL return the video purchased and not the first one. So far, the solution proposed by Jim is the only one I was able to achieve that from.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform