I want to write below SQL Statement in excel macro which I pulled from MS Access query since I have the same access db's table data in my excel sheet, i want to run the query in excel to get the output instead of using MS Access.
Also I want to add an additional condition to the below SQL statement, that is to also exclude the rows which shouldn't be captured in output for e.g. if the total sum of Qty column for Trade Exec row items is 10 and Total Sum of Trade Alloc row items is 22 then Macro should take only those rows for which the sum total of Trade Alloc label row items (along with Trade Exec label row items) is 10 and copy the same to next sheet.
MS Access Query SQL Statement:
MS Excel VBA SQL Statement which I have got so far:
Also I want to add an additional condition to the below SQL statement, that is to also exclude the rows which shouldn't be captured in output for e.g. if the total sum of Qty column for Trade Exec row items is 10 and Total Sum of Trade Alloc row items is 22 then Macro should take only those rows for which the sum total of Trade Alloc label row items (along with Trade Exec label row items) is 10 and copy the same to next sheet.
MS Access Query SQL Statement:
Code:
SELECT [Sample Rec Data].[Name of Client], [Sample Rec Data].Price, Sum([Sample Rec Data].Qty) AS SumOfQty, [Sample Rec Data].Label
FROM [Sample Rec Data]
GROUP BY [Sample Rec Data].[Name of Client], [Sample Rec Data].Price, [Sample Rec Data].Label
HAVING ((([Sample Rec Data].Label)='TRADE ALLOC' Or ([Sample Rec Data].Label)='TRADE EXEC'));
MS Excel VBA SQL Statement which I have got so far:
Code:
sSQLSting = "SELECT [Sample Rec Data$].[Name of Client], [Sample Rec Data$].[Price],[Sample Rec Data].Label, SUM([Sample Rec Data].[Qty]) " & _
"FROM [Sample Rec Data$]" & _
"GROUP BY [Sample Rec Data$].[Name of Client], [Sample Rec Data$].[Price], [Sample Rec Data$].[Label]"