AOB
Registered User.
- Local time
- Today, 06:52
- Joined
- Sep 26, 2012
- Messages
- 633
Hi there,
I have a SQL query to gather data from a number of tables (balances, accounts, currencies)
How do I add 'AmountUSD' to the WHERE clause (such that I can only return records above or below a certain value, for example)
Along the lines of :
I know it's an issue with referring to aggregated functions in the WHERE clause and you're supposed to use HAVING instead - but can't figure out how?
Any suggestions?
Thanks
AOB
I have a SQL query to gather data from a number of tables (balances, accounts, currencies)
SELECT [tblBalances].[BalanceDate], [tblAccounts].[AccountNumber], [tblCurrencies].[Ccy], [tblBalances].[Amount], ([tblBalances].[Amount]*[tblRates].[FXRate]) AS AmountUSD
FROM (([tblBalances] INNER JOIN [tblAccounts] ON [tblBalances].[AccountID]=[tblAccounts].[AccountID]) INNER JOIN [tblCurrencies] ON [tblBalances].[CcyID]=[tblCurrencies].[CcyID]) INNER JOIN [tblRates] ON ([tblBalances].[BalanceDate]=[tblRates].[RateDate]) AND ([tblBalances].[CcyID]=[tblRates].[CcyID])
WHERE BalanceDate = #12/10/2013#
How do I add 'AmountUSD' to the WHERE clause (such that I can only return records above or below a certain value, for example)
Along the lines of :
WHERE BalanceDate = #12/10/2013# AND AmountUSD>1000
I know it's an issue with referring to aggregated functions in the WHERE clause and you're supposed to use HAVING instead - but can't figure out how?
Any suggestions?
Thanks
AOB