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

Help with complicated script

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
or at least for me. I have two tables (a and b). table a houses unique records (i.e. pricing information). table b houses invoicing information). here's the tricky part.

I am trying to create a report which will list all the items including what has been invoiced. I have been able to get the join down (or so i thought) but i am getting duplicate records since table two contains at times two entries for one item in table a.

Table A

NUMBER LINEITEM COST
100 1 1000

Table B

NUMBER PNUMBER INVCOST
1 100 600
2 100 400

So my report looks like this:

Purchasing Details:

NUMBER LINEITEM COST INVCOST
100 1 1000 600
100 1 1000 400

Totals:
Total Purchased Price: 2000 Total Invoiced Price: 1000

How do I go about correcting the double records?

Please let me know if you need more information.

thx
 
add grouping to the invcost field

select a.number, a.cost, sum(b.invcost) from
tableA a,
tableB b
where a.number = b.pnumber
group by b.pnumber


something like that


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top