Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need advice on SQL
Message
De
17/09/2006 02:02:18
 
 
À
16/09/2006 21:30:01
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:
01154450
Vues:
9
>From the following SQL, I obtain some video information in regards to the video purchased by a user, when the video is part of a program. A program contains multiple videos.
>
>
>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;
> ORDER BY Program.Title
>
>
>This works well. For each purchased video part of a program, I obtain the program information, the related master information as well as the video information.
>
>What I need to do from this SQL is to get the first video of the program. So, if a program contains video 11, 13, 33, 45 and the user purchases video 13 and 33, I need to obtain 11 because this video ID was created the first one in the program. Based on that SQL result, what can I add to achieve that?
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(Numero) FROM Video V WHERE V.NoProgram=Video.NoProgram);
 ORDER BY Program.Title
)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform