Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with Select SQL
Message
De
11/03/2003 11:22:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/03/2003 10:26:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00764238
Message ID:
00764285
Vues:
21
>Hi to all.
>I have 3 tables : Table1 , Table2 y Table3
>
>
>Table1 : table1.id, table1.desc
>Table2 : table2.id, table2.table1_id, table2.desc
>Table3 : table3.id, table3.table1_id, table3.fecha
>
>
>table1.id table1.desc
>-------------------------
>1 Pedro
>2 Juan
>3 Alberto
>
>
>
>table2.id table2.desc table2.table1_id
>----------------------------------------
>100 casa 1
>101 auto 1
>102 casa 2
>103 yate 2
>104 auto 3
>105 casa 3
>
>
>table3.id table3.date table3.table1_id
>------------------------------------------
>1000 01/10/2002 1
>1001 06/10/2002 1
>1002 07/11/2002 2
>1003 08/11/2002 2
>1004 08/11/2002 3
>1005 10/11/2002 3
>
>
>I would like the query to return the folowing results based on the tables definition listed above using the MAX value for table3.date
>
>
>table1.id table1.nombre table2.desc table3.id
>---------------------------------------------------------
>1 Pedro casa 1001
>1 Pedro auto 1001
>2 Juan casa 1003
>2 Juan yate 1003
>3 Alberto auto 1005
>3 Alberto casa 1005
>
>
>Thanks.
SELECT t1.id, t1.desc, t2.desc, t3.id ;
 FROM t3 ;
 inner join t1 on t3.t1id = t1.id ;
 inner join t2 ON t2.t1id = t1.id ;
 where t3.date = ;
 (select max(date) FROM t3 t3_2 WHERE t3_2.t1id = t3.t1id)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform