Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by in a union clause error, (not the usual one)
Message
From
04/10/2005 16:09:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01056034
Message ID:
01056049
Views:
18
>I've got a view that looks like this...
>
>Select xtable.id from Xtable where xtable.id in (select min(xtable.id) from xtable group by xtable.foreignkey)
>
>It's a view to return the first address for each person that has addresses. (Yep, likely not the best way to do this but its what I've been given to work with at the moment.)
>
>Now for the funny part. This select statement works fine if you simply run it in the command window. And the view works fine if you just open the view.
>
>But, if you try using the view designer or if you query the view with the nodata clause, fox returns an (invalid group by clause) error.
>
>So far as I can tell its a perfectly legal construction, and the sub-select works fine by itself. And as mentioned the syntax works "most of the time".
>
>I tried moving the select into the from clause and doing a join on it, but got the same behavior. I tried similar constructions with different tables in the main and sub selects (just to test the limits of the problem) but got the same results all around.
>
>Anyone seen this wierdness and managed to overcome it?

I don't have VFP9 here to test. Does this work?
Select xtable.id from Xtable t1 ;
   where id = ;
  (select min(id) from xtable t2 where t1.foreignkey = t2.foreignkey)
PS:It looks kinda strange to me to get an id you do a subquery? Sounds like would be select * from xtable1 t1 ...
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform