Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL syntax help with a subquery
Message
From
30/11/2006 19:40:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
30/11/2006 19:37:23
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Miscellaneous
Thread ID:
01173944
Message ID:
01173959
Views:
9
>Thanks for the reply.
>
>Unfortunately, this query returns more than one child record for the same parent.

If my query is correctly designed - which I am not entirely sure! - this would happen if there were two children with the same area. (Do you think this is the case?)

See if the following modification works:
select b_pk, max(b_area) from ChildTable;
  group by b_pk;
  into cursor Tmp
select Tmp.*, max(b.b_name);
  from Tmp join ChildTable b on Tmp.b_pk = b.b_pk and Tmp.b_area = b.b_area;
  group by Tmp.b_pk, b_area;
  into cursor Tmp
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform