Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group by error
Message
De
23/06/2003 10:12:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/06/2003 09:51:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00802887
Message ID:
00802897
Vues:
16
>I need to retrieve the pi_id for the latest expdate by pitype. in vfp 7 I would do:
>
>
>SET ENGINEBEHAVIOR 70
>SELECT ;
>	pi_id,;
>	pitype_id,;
>	MAX(expdate);
>	FROM PI ;
>	WHERE eqtype_id=2 AND equip_id=2246 ;
>	GROUP BY 2;
>	INTO CURSOR cc1
>
>
>in vfp 8 that gives me a group by error
>
>
>SET ENGINEBEHAVIOR 80
>SELECT ;
>	pi_id,;
>	pitype_id,;
>	MAX(expdate);
>	FROM PI ;
>	WHERE eqtype_id=2 AND equip_id=2246 ;
>	GROUP BY 1,2;
>	INTO CURSOR cc1
>
>
>works but gives me all records because pi_id is the unique primary key (which i AM AFTER)
>
>
>What to do?
>
>Peter
SELECT ;
	pi_id,;
	pitype_id,;
	expdate ;
	FROM PI t1 ;
	WHERE eqtype_id=2 AND equip_id=2246 ;
          and expdate = ;
         (select max(expdate) from pi t2 where t1.pitype_id = t2.pitype_id) ;
	INTO CURSOR cc1
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