JerryEng
01-09-2004, 01:45 PM
Is this possible??
I have a table called "Jobs" with the following fields:
JobNum(key); Desc;Amount; JobType; PrimaryJob
JobType is either a 1 or 2; 1 indicates a primary contract job, 2 indicates a "change order" to an existing contract job. If the job is a primary contract, then primaryjob is the same as jobnum. If the job is a change order, then primary job is the jobnum of the primary contract
I would like to create a SELECT statement that gives me the following:
JobNum; Desc; Sum(amount) Where JobType = 1
but I want Sum(amount) to sum where PrimaryJob is the same.
Example: the following table would return:
JobNum; Desc; Amount; JobType; PrimaryJob
1 Bank 25000 1 1
2 Bakery 35000 1 2
3 change1 1000 2 1
4 change2 2000 2 1
5 change1 500 2 2
result:
1 Bank 28000
2 Bakery 35500
I have a table called "Jobs" with the following fields:
JobNum(key); Desc;Amount; JobType; PrimaryJob
JobType is either a 1 or 2; 1 indicates a primary contract job, 2 indicates a "change order" to an existing contract job. If the job is a primary contract, then primaryjob is the same as jobnum. If the job is a change order, then primary job is the jobnum of the primary contract
I would like to create a SELECT statement that gives me the following:
JobNum; Desc; Sum(amount) Where JobType = 1
but I want Sum(amount) to sum where PrimaryJob is the same.
Example: the following table would return:
JobNum; Desc; Amount; JobType; PrimaryJob
1 Bank 25000 1 1
2 Bakery 35000 1 2
3 change1 1000 2 1
4 change2 2000 2 1
5 change1 500 2 2
result:
1 Bank 28000
2 Bakery 35500