Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Question on getting unique records without aggregate
Message
 
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01097648
Message ID:
01097689
Views:
10
This message has been marked as a message which has helped to the initial question of the thread.
You can also use derived table (new in VFP9)
SELECT cus.* FROM customer cus
	JOIN (
		SELECT DISTINCT customer_no, region_no FROM orders
		) ord
	ON ord.customer_no = cus.customer_no
		AND ord.region_no = cus.region_no
>I have a customer table and an orders table. I want a cursor of all custmers who have had an order, with no duplicates on customer_no and region_no (together they make a unique key), and the output cursor needs to be in the same structure as the customer table. There are hundreds of fields in the customer table and I do not want to put an aggregate on each field, this is the problem. I know to join the customer table and the orders table on customer_no. But there could be duplicates returned and I want to GROUP BY customer_no, but I do not want to put an aggregate on each customer table field.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform