Query/SQL help

J

Joe O

I have two tables

Table1
Item# -Descr-Amt
xyz1- Orange - 250.00
xyz2 - Apple - 350.00

Table 2
Item#-Tax-Amt
xyz1-Tax1- 2.50
xyz1-Tax2-3.50
xyz2-Tax1-3.00
xyz2-Tax2-4.20

I will like have a query to show data as
Item#-Descr-Amt-Tax1-Tax2
xyz1-Orange-250.00-2.50-3.50
xyz2-Apple-350.00-3.00-4.20

Thanks for any help.
 
G

Guest

Try this query

select a.Item# , Descr , a.Amt , b.Amt as Tax1 , ( select e.Amt
from
table1 d ,
table2 e
where

d.Item# = e.Item#
and Tax = 'Tax2' and d.Item#
= a.Item#
and a.Descr = d.Descr
) as Tax2
from table1 a ,
table2 b
where a.Item# = b.Item# and Tax = 'Tax1'
 
J

Joe O

Thanks Adam,Tarik... I am checking out the tips

Tarik said:
Try this query

select a.Item# , Descr , a.Amt , b.Amt as Tax1 , ( select e.Amt
from
table1 d ,
table2 e
where

d.Item# = e.Item#
and Tax = 'Tax2' and d.Item#
= a.Item#
and a.Descr = d.Descr
) as Tax2
from table1 a ,
table2 b
where a.Item# = b.Item# and Tax = 'Tax1'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

One to many Relationship in one record 6
I think this is simple... 1
Macro Help in Pivot 2
last, first, etc 2
Lookup 5
Using IN( ) function in a query 7
Query Challenge 1
Query help 3

Top