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
|
|||
|
|||
AT WITS END ON QUERY TOTAL
I want to thank anyone in advance for any insight into this. I have posted
this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#2
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Lmiller -
John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#3
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Thanks Daryl,
but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#4
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Lmiller -
Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#5
|
|||
|
|||
AT WITS END ON QUERY TOTAL
SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING
INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#6
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Lmiller -
Are you building this final query in design mode? That should make it easy. Add the three source queries. You will need to adjust the joins by double-clicking on them, and selecting the "All from COMBINED" option for the joins between the COMBINED query and the other two sources. Delete any join between the other two queries. Then, add the fields to the query grid by double-clicking on the [PART #] and [PART NAME] fields in the COMBINED query. Then add the [END BALANCE 7] and [END BALANCE 8] fields in the same manner. Finally, in the last column, type in: SUM OF BALANCES: =nz([END BALANCE 7],0) + nz([END BALANCE 8],0) -- Daryl S "lmiller" wrote: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#7
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Try these queries --
qryINVENTORY_RD_7_8 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7], 0 AS [END BALANCE 8] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); UNION ALLSELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], 0 AS [END BALANCE 7], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); SELECT [PART #], [PART NAME], [END BALANCE 7], [END BALANCE 8], Sum(Nz([END BALANCE 7], 0) + Nz([END BALANCE 8], 0)) AS Combined_Balance FROM qryINVENTORY_RD_7_8 GROUP BY [PART #], [PART NAME], [END BALANCE 7], [END BALANCE 8]; -- Build a little, test a little. "lmiller" wrote: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#8
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Tried what you suggested, this is what it comes up as now in SQL
SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; Now the query only list the part #'s that were in my 8th term with the 7th term balance PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 27 27 1234 test 0 what happened to all my other part # and their balances? "Daryl S" wrote: Lmiller - Are you building this final query in design mode? That should make it easy. Add the three source queries. You will need to adjust the joins by double-clicking on them, and selecting the "All from COMBINED" option for the joins between the COMBINED query and the other two sources. Delete any join between the other two queries. Then, add the fields to the query grid by double-clicking on the [PART #] and [PART NAME] fields in the COMBINED query. Then add the [END BALANCE 7] and [END BALANCE 8] fields in the same manner. Finally, in the last column, type in: SUM OF BALANCES: =nz([END BALANCE 7],0) + nz([END BALANCE 8],0) -- Daryl S "lmiller" wrote: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#9
|
|||
|
|||
AT WITS END ON QUERY TOTAL
Karl, The first query "qryINVENTORY_RD7_8" resulted in nothing coming back: when I ran it had no data SELECT [INVENTORY RD 7TH].[PART #], [INVENTORY RD 7TH].[PART NAME],[INVENTORY RD 7TH].[END BALANCE 7], 0 AS [END BALANCE 8] FROM [INVENTORY RD 7TH] WHERE ((([INVENTORY 7TH].[END BALANCE 7])0)); UNION ALL SELECT [INVENTORY RD 8TH].[PART #],[INVENTORY RD 8TH].[PART NAME], 0 AS [END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8] FROM [INVENTORY RD 8TH] WHERE ((([INVENTORY RD 8TH].[END BALANCE 8])0)); I went ahead and tried the 2nd query but kept getting a syntax error in the from statement..... "KARL DEWEY" wrote: Try these queries -- qryINVENTORY_RD_7_8 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7], 0 AS [END BALANCE 8] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); UNION ALLSELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], 0 AS [END BALANCE 7], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); SELECT [PART #], [PART NAME], [END BALANCE 7], [END BALANCE 8], Sum(Nz([END BALANCE 7], 0) + Nz([END BALANCE 8], 0)) AS Combined_Balance FROM qryINVENTORY_RD_7_8 GROUP BY [PART #], [PART NAME], [END BALANCE 7], [END BALANCE 8]; -- Build a little, test a little. "lmiller" wrote: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
#10
|
|||
|
|||
AT WITS END ON QUERY TOTAL
LMiller -
Progress! I think I see values for END BALANCE 7 (the 27 and the null), and the sums, but nothing for the END BALANCE 8. I would check the source query to see if you really have something in [END BALANCE 8]. Maybe there is a typo? The query is pulling the correct records, and you are getting one from each of the source records, but the [END BALANCE 8] is not coming through. Can you check your [INVENTORY BALANCE 8TH] query to make sure you are getting data in the [END BALANCE 8] column? -- Daryl S "lmiller" wrote: Tried what you suggested, this is what it comes up as now in SQL SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; Now the query only list the part #'s that were in my 8th term with the 7th term balance PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 27 27 1234 test 0 what happened to all my other part # and their balances? "Daryl S" wrote: Lmiller - Are you building this final query in design mode? That should make it easy. Add the three source queries. You will need to adjust the joins by double-clicking on them, and selecting the "All from COMBINED" option for the joins between the COMBINED query and the other two sources. Delete any join between the other two queries. Then, add the fields to the query grid by double-clicking on the [PART #] and [PART NAME] fields in the COMBINED query. Then add the [END BALANCE 7] and [END BALANCE 8] fields in the same manner. Finally, in the last column, type in: SUM OF BALANCES: =nz([END BALANCE 7],0) + nz([END BALANCE 8],0) -- Daryl S "lmiller" wrote: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([END BALANCE 7],0)+nz([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ( [BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART#] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; I am trying but it keeps giving me an error on the [BEGINNING INVENTORY BALANCE 8TH].[PART #] can refer to more than one table in my SQL statement...... "Daryl S" wrote: Lmiller - Try this one (I switched the outer joins to a way I am more used to - it works in my db): SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [INVENTORY RD 8TH].[END BALANCE 8], NZ([END BALANCE 7],0)+NZ([END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([BEGINNING INVENTORY BALANCE 8TH] RIGHT JOIN [COMBINED PARTS] ON [BEGINNING INVENTORY BALANCE 8TH].[PART #] = [COMBINED PARTS].[PART #]) RIGHT JOIN [INVENTORY RD 8TH] ON [COMBINED PARTS].[PART #] = [INVENTORY RD 8TH].[PART #]; -- Daryl S "lmiller" wrote: Thanks Daryl, but I had already tried that when John suggested it - same result: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 "Daryl S" wrote: Lmiller - John Vinson actually caught this error - change the ampersand to an equal sign in the first join. Try this: SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] = [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; -- Daryl S "lmiller" wrote: I want to thank anyone in advance for any insight into this. I have posted this question a couple of times and have been working on developing this query for 2 weeks and to no avial. I have a query that list my 7th term inventory balances as: PART # PRODUCT DESCRIPTION END BALANCE 7 1018 "OD 12.7MM X 24"" LONG" 27 11509671 BOLT-METRIX HEX FLANGE 93 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 25 11588324 NUT WELD HEX FLANGE (M10X1.5) 172 11588325 NUT WELD HEX FLANGE (M12X1.75) 55 SELECT [INVENTORY RD 7th].[PART #], [INVENTORY RD 7th].[PART NAME], [INVENTORY RD 7th].[END BALANCE 7] AS [END BALANCE 7] FROM [INVENTORY RD 7th] WHERE ((([INVENTORY RD 7th].[END BALANCE 7])0)); my 8th term inventory balances as follows: PART # PRODUCT DESCRIPTION END BALANCE 8 1018 "OD 12.7MM X 24"" LONG" 2 1234 test 1 SELECT [inventory rd 8th].[PART #], [inventory rd 8th].[PART NAME], [inventory rd 8th].[END BALANCE 8] FROM [inventory rd 8th] WHERE ((([inventory rd 8th].[END BALANCE 8])0)); I am trying to combine the 2 queries into 1 so that all part #'s list and if they are like part # to list on just one line. Also I would like the balances from each term to be added together. I made a union query for the Part # and name and it works great. I am trying to get the balances now to add or display correctly. Here is what I have come up with thus far : PART # PART NAME END BALANCE 7 END BALANCE 8 SUM OF BALANCES 1018 "OD 12.7MM X 24"" LONG" 0 11509671 BOLT-METRIX HEX FLANGE 0 11515781 GEAR BOX ASSEMBLY STEERING FIXING BOLT 0 11588324 NUT WELD HEX FLANGE (M10X1.5) 0 11588325 NUT WELD HEX FLANGE (M12X1.75) 0 11589252 GMT319 L4 BOLT 0 1234 test 0 SELECT [COMBINED PARTS].[PART #], [COMBINED PARTS].[PART NAME], [BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7], [inventory rd 8th].[END BALANCE 8], nz([BEGINNING INVENTORY BALANCE 8TH].[END BALANCE 7],0)+nz([inventory rd 8th].[END BALANCE 8],0) AS [SUM OF BALANCES] FROM ([COMBINED PARTS] LEFT JOIN [BEGINNING INVENTORY BALANCE 8TH] ON [COMBINED PARTS].[PART #] & [BEGINNING INVENTORY BALANCE 8TH].[PART #]) LEFT JOIN [inventory rd 8th] ON [COMBINED PARTS].[PART #]=[inventory rd 8th].[PART #]; Everything I have tried doesn't produce the balances. Any suggestion or ideas. Maybe I need a whole different query than the one I have come up with, I have played with many but as I said to no avail. THANKS!!! |
Thread Tools | |
Display Modes | |
|
|