Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Exists Clause

Status
Not open for further replies.

OV

Programmer
Nov 4, 2002
57
0
0
US
I have the following problem. For every job in the database we can have one or more salesperson. Example:

Job Salesperson Sales
1 1 $100
1 2 $150
1 3 $120
2 1 $300

Total sales of salesperson 1 in this case would be $100+$300=$400. However, some users are asking all the sales in which salesperson 1 participates; in my example that would be 100+150+120+300=670
In SQL:
Select sum(Sales) from Fact_Sales A
where exists (Select * from Fact_Sales B
where A.Job=B.Job
and Salesperson=1)

How do I do this? We are in version 7.2.3
Thanks, OV

 
Never mind. I did it, using a relationship filter.
OV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top