Microsoft Access 2003: How can I make the value of a WHERE in SQL SELECT statement depend on a field within…?
Microsoft Access 2003: How can I make the value of a WHERE in SQL SELECT statement depend on a field within the query?
For example: In XYZ Query, having Field1, Field2, Field3, Field3 has a SQL SELECT * FROM ABC Table WHERE Field1 (from ABC Table) = Field1 (from XYZ Query). I want to make it so that the value in Field1 (ABC Table) will be filtered depending on the value of Field1 (XYZ Query).
Specifically: I have a table named Table1 with fields SNumber and Quantity. The value of the fields are as follows respectively: 001, 10; 001, 15; 001, 30; 002, 25; 003, 35; 004, 5; 004, 15. I have a query named Query1 that shows the total of Table1 with fields SNumber and Total. The value of SNumbers are those the value of SNumbers from Table1 but with duplicates such as 001; 002; 003; 004 only and will show the total of the Quantity from Table1.
I made an expression in Query1, Total (field): (SELECT SUM(Quantity) FROM Table1 WHERE SNumber(*this refers to SNumber of Table1)=How(*The SNumber field from Query1)). I want the query to filter the quantity to sum.
The query should produce this output:
Query1
SNumber——–Total
001—————-55
002—————-25
003—————-35
004—————-20
Based on the data from this table
Table1
SNumber——–Quantity
001—————-10
001—————-15
001—————-30
002—————-25
003—————-35
004—————-5
004—————-15
Please send me a YM at goshenite_2004 for more info.
SELECT SNumber, SUM(Quantity) As Total FROM Table1
GROUP BY SNumber