Subject | Re: Sub select with function max problem |
---|---|
Author | Svein Erling |
Post date | 2004-02-20T08:51:43Z |
Use aliases EVERYWHERE. I.e. change to
Select d.deptid, d.deptcode, d.deptname, d.deptno
from deptsections d
where d.deptid = (
Select first 1 a1.deptid
from atdhistory_temp a1
where a1.empid = :empid_2
and a1.workdate = (
Select max( a2.workdate )
from atdhistory_temp a2
where a2.workdate between :mulai and :mulai
+ 6
and a2.empid = :empid_2
)
)
into :deptid_2, :deptcode_2, :deptname_2, :deptno_2;
I don't know whether this is your problem or not, but it is a good
habit to use aliases and without them I never know how Firebird reads
my query. Report back if this solves your problem, or if we have to
look closer at your code.
HTH,
Set
- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
Select d.deptid, d.deptcode, d.deptname, d.deptno
from deptsections d
where d.deptid = (
Select first 1 a1.deptid
from atdhistory_temp a1
where a1.empid = :empid_2
and a1.workdate = (
Select max( a2.workdate )
from atdhistory_temp a2
where a2.workdate between :mulai and :mulai
+ 6
and a2.empid = :empid_2
)
)
into :deptid_2, :deptcode_2, :deptname_2, :deptno_2;
I don't know whether this is your problem or not, but it is a good
habit to use aliases and without them I never know how Firebird reads
my query. Report back if this solves your problem, or if we have to
look closer at your code.
HTH,
Set
- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation