Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to subquery in VFP 8
Message
De
05/09/2005 17:50:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
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 8 SP1
Divers
Thread ID:
01046845
Message ID:
01046850
Vues:
16
>I combine two fields from the same table into one field (with the help from Fabio and Sergey in another thread).
>
>Now I need to select only some records from the resulting cursor. And to do that, as far as I know, I need to run a subquery within a SQL Select. But there I get an error that the table does not exist.
>
>Here is an example:
>
>The cursor MYCURS:
>
>ROOM RES_TIME PK_VALUE
>A100 11:00 3434
>A100 15:00 34566
>B100 15:00 2
>B100 17:00 899
>and so one
>
>I need to select only those records that match the latest Reservation time. That is, in the example above, the resulting cursor would have:
>
>A100 15:00
>B100 17:00
>
>So what I do is the following
>
>
>select * from MYCURS1 where PK_VALUE = MyFunc(ROOM) into cursor MYCURS2
>
>Function MyFunc
>lparameter	tcRoomNum
>local array	laKeys[1]	
>select top 1 RESER_PK, END_TIME from MYCURS1 		;
>where ROOM == tcRoomNum order by END_TIME descending into array laKeys
>IF _tally > 0
>	RETURN laKeys[1]
>ELSE
>	RETURN 0
>endif		
>RETURN
>
>
>And I get error in the Select TOP 1 that cursor/table MYCURS1 does not exist.
>
>How could I fix this?
>
>Thank you.
select * from myCurs1 c1 ;
  where end_time = ;
  (select max(end_time) from myCurs1 c2 where c1.room == c2.room)
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