Subject | RE: [firebird-support] having max() doesn't work in Firebird |
---|---|
Author | Bill Meaney |
Post date | 2004-06-01T20:27:06Z |
Nando,
Thank you. I added b.EffDt to the SELECT and GROUP BY clauses and it
worked.
Bill
B> The error indicates that Max() can no longer be used in the having
clause.
not really. See below.
B> select b.CntId, Prd.Dsc, max(a.EffDt)
B> from Cnt a, Cnt b, Prd, SchCtl
B> where a.CntEntId = b.CntEntId
B> and a.PrdId = b.PrdId
B> and b.PrdId = Prd.PrdId
B> and a.CntEntId = 2
B> and Prd.PyrId = 8
B> and a.CntId = SchCtl.CntId
B> group by b.CntId, Prd.Dsc
B> having b.EffDt = max(a.EffDt) <--- gives error message below
B> order by Prd.Dsc
B> Error message: Invalid expression in the HAVING clause (neither an
aggregate
B> function nor a part of the GROUP BY clause)
B> I set the group by to look like this:
B> group by b.CntId, Prd.Dsc, max(a.EffDt)
B> and that didn't work either.
B> Any suggestions?
N> Yes. This query doesn't make sense and you should thank Firebird for
N> telling you. :-) The problem is that you can only include in the HAVING
N> clause columns that are also parte of the GROUP BY clause or aggregate
N> functions. b.EffDt doesn't satisfy the requirement.
N> I haven't got a clue what kind of result you expect, but I hope this
N> information will be useful to fix your query.
Ciao
--
Nando Dessena
Thank you. I added b.EffDt to the SELECT and GROUP BY clauses and it
worked.
Bill
B> The error indicates that Max() can no longer be used in the having
clause.
not really. See below.
B> select b.CntId, Prd.Dsc, max(a.EffDt)
B> from Cnt a, Cnt b, Prd, SchCtl
B> where a.CntEntId = b.CntEntId
B> and a.PrdId = b.PrdId
B> and b.PrdId = Prd.PrdId
B> and a.CntEntId = 2
B> and Prd.PyrId = 8
B> and a.CntId = SchCtl.CntId
B> group by b.CntId, Prd.Dsc
B> having b.EffDt = max(a.EffDt) <--- gives error message below
B> order by Prd.Dsc
B> Error message: Invalid expression in the HAVING clause (neither an
aggregate
B> function nor a part of the GROUP BY clause)
B> I set the group by to look like this:
B> group by b.CntId, Prd.Dsc, max(a.EffDt)
B> and that didn't work either.
B> Any suggestions?
N> Yes. This query doesn't make sense and you should thank Firebird for
N> telling you. :-) The problem is that you can only include in the HAVING
N> clause columns that are also parte of the GROUP BY clause or aggregate
N> functions. b.EffDt doesn't satisfy the requirement.
N> I haven't got a clue what kind of result you expect, but I hope this
N> information will be useful to fix your query.
Ciao
--
Nando Dessena