Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Statement
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01179984
Message ID:
01180057
Views:
24
>Hi John,
>
>You didn't mention before that there are possible multiple contribution per name and official combination.
>Here's a query that works on your test data. The new inner subquery gets unique combinations of name&official for specified criteria. The rest is the same as before.
>SELECT name, amount, official, date FROM cmoney ;
>	WHERE official IN (?Official1, ?Official2) ;
>		AND name IN ( ;
>			SELECT name FROM ( ;
>					SELECT name, official FROM cmoney ;
>			              WHERE official = ?Official1 or official = ?Official2 ;
>			             GROUP BY 1,2 ) ds1 ;
>			             GROUP BY 1 HAVING COUNT(*) > 1 ;
>             	) ;
>
>
Once more, let it be said far and wide - Sergey is the SQL Man!

Thanks Sergey it works wonderfully! This will be a keeper snippet.

John
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform