Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One SQL, two SQLs, three SQLs, four...
Message
 
 
To
21/01/2003 18:47:04
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00744004
Message ID:
00744070
Views:
10
You can use derived table.
select dt1.pkfield, dt1.maxfield, table1.anotherfield 
	from (SELECT pkfield, max(field2) as maxfield from table1 
		group by pkfield ) dt1 
	inner join table1 on table1.pkfield = dt1.pkfield 
>Amazing!
>
>I would not have guessed that you can perform a select to produce a column! If we can't do that in VFP, they should add that in!
>
>BUT! I still think I need 2 selects. No one has yet answered how I can do two consecutive selects! I have 2 tables. The second table is a log of events. I want to grab fields besides the Max() one from the record with the max date.
>
>>
select pkfield, table1.anotherfield,
>> ( SELECT max(field2) from table1 t12 where t11.pkfield = t12.pkfield) as maxfield
>>from table1 t11
>>
>>>Hi Fred
>>>
>>>I really must have two consecutive SQLs as I need MaxField in the final output. Your answer was right, since I asked the wrong question! The second SQL should have been ...
>>>
>><snip>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform