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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL between two tables

Status
Not open for further replies.

Vandy02

Programmer
Jan 7, 2003
151
US
I hope someone can help?

I have two tables (Workorder and labtrans)
Labtrans stores multiple entries of labor entries per workorder. I have found an error in the database with respect to costing. I need to look at the ACTLABCOST of workorder and compare it with that of the summation of linecosts of the labtrans table. I want to be able to look at those that are the same first. Note that the wonum in each table is the link, so they have to be equal.
SQL> edit
Wrote file afiedt.buf

1 select a.wonum
2 from workorder a
3* where a.ACTLABCOST = (select sum(labtrans.linecost) from labtrans group by labtrans.wonum where labtrans.wonum = a.wonum)
SQL> /
where a.ACTLABCOST = (select sum(labtrans.linecost) from labtrans group by labtrans.wonum where labtrans.wonum = a.wonum)
*
ERROR at line 3:
ORA-00907: missing right parenthesis
 
I got it, but can I add wonum to the select statement?
I keep getting an error

select sum(a.linecost), sum(b.actlabcost), sum(b.wonum)
from labtrans a, workorder b
where a.wonum = b.wonum
group by a.wonum
 
hi,

it should be:

select a.wonum
from workorder a
where a.ACTLABCOST IN (select sum(labtrans.linecost)
from labtrans
group by labtrans.wonum
where labtrans.wonum = a.wonum)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top