| Author |
Topic  |
|
|
mitasid
Yak Posting Veteran
New Zealand
51 Posts |
Posted - 08/21/2006 : 23:47:56
|
Hi Guys
I need to use 3 conditions using AND in my query. Its in the following format:
SELECT Indicatorid, DHBName, PHOName, PracticeName, SUM(Numerator) AS Expr1, SUM(Denominator) AS Expr2 FROM PhoNew GROUP BY Indicatorid, DHBName, PHOName, PracticeName HAVING indicator id = 1 AND dhb name = 'canterbury dhb ' AND practicename = 'canterbury community pho- 585342'
If i use two conditions in AND, query works correctly but when i use the third conditions, I get a syntax error
Please help
Thanks Mita |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16769 Posts |
Posted - 08/21/2006 : 23:56:18
|
quote:
HAVING indicator id = 1 AND dhb name = 'canterbury dhb ' AND practicename = 'canterbury community pho- 585342'
it should be Indicatorid and DHBName is it ?
"I get a syntax error" What is the error message ?
KH
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 08/22/2006 : 00:54:27
|
Also put these comparisons at WHERE, not HAVING.
Peter Larsson Helsingborg, Sweden |
 |
|
|
Lumbago
Norsk Yak Master
Norway
3246 Posts |
Posted - 08/22/2006 : 08:55:14
|
As Peso is saying you need to use the WHERE-statement instead. HAVING is like the WHERE but for the aggregated columns instead. Example:
SELECT Indicatorid, DHBName, PHOName, PracticeName, SUM(Numerator) AS Expr1, SUM(Denominator) AS Expr2 FROM PhoNew WHERE Indicatorid = 1 AND DHBName = 'canterbury dhb ' AND practicename = 'canterbury community pho- 585342' GROUP BY Indicatorid, DHBName, PHOName, PracticeName HAVING SUM(Numerator) > 52 AND SUM(Denominator) < 4
-- Lumbago "Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
| |
Topic  |
|
|
|