Query

F

finster26

I have one table with:
YR CODE COST
2010 OL $5.50
2010 CG $1.28
2010 SW $2.25

A second table:
ST YR CODE CG SW
MAIN 2010 OL Y Y

I can achieve by a query "MAIN, 2010, OL, $5.50".

But what I need to do is when CODE="OL" then when CG="Y" or when SW="Y" to
up with:

"MAIN, 2010, OL, $5.50, $1.28, $2.25"

Thanks for your help.
 
K

KARL DEWEY

This works on the data you posted but it does not make sense to me.
SELECT Second_Table.ST, Second_Table.YR, Second_Table.CODE,
Format([One_Table].[Cost],"$0.00") & ", " &
Format([One_Table_1].[Cost],"$0.00") & ", " &
Format([One_Table_2].[Cost],"$0.00") AS Cost_
FROM ((Second_Table LEFT JOIN One_Table ON Second_Table.YR = One_Table.YR)
LEFT JOIN One_Table AS One_Table_1 ON Second_Table.YR = One_Table_1.YR) LEFT
JOIN One_Table AS One_Table_2 ON Second_Table.YR = One_Table_2.YR
WHERE (((Second_Table.CODE)="OL") AND ((One_Table.CODE)="OL") AND
((One_Table_1.CODE)="CG") AND ((One_Table_2.CODE)="SW"));
 

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

Top