If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Query
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. |
#2
|
|||
|
|||
Query
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")); "finster26" wrote: 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. |
Thread Tools | |
Display Modes | |
|
|