Subject | strange select behaviour |
---|---|
Author | henry FRANQUET |
Post date | 2004-11-05T22:54:41Z |
Hi,
I have an application in which I can send SQL orders but only on the
where clause.
Here some strange results with one table T_PROSP, a primary key NUM
and a field TEL and Firebird 1.5 4418
1) Select P.TEL from T_PROSP P
where not singular (select PP.NUM from T_PROSP PP
where PP.TEL = P.TEL)
order by P.TEL
give correct result : all records with not unique TEL
but alas, as I can't chang the select clause I have to send :
2) Select T_PROSP.TEL from T_PROSP
where not singular (select PP.NUM from T_PROSP PP
where PP.TEL = T_PROSP.TEL)
order by T_PROSP.TEL
wich gave no result !
more strange
3) Select T_PROSP.TEL from T_PROSP
where 1 < (select count(*) from T_PROSP PP
where PP.TEL = T_PROSP.TEL)
order by T_PROSP.TEL
give all records! (and using an alias for first T_PROSP give correct
result)
except as using a stored proc with execute statement inside,
what coukd be the correct syntaxe to obtain what I need (records
having duplicate TEL) with an sql order starting with
select T_PROSP.TEL from T_PROSP
... my clause where
order by T_PROSP.TEL
thanks
I have an application in which I can send SQL orders but only on the
where clause.
Here some strange results with one table T_PROSP, a primary key NUM
and a field TEL and Firebird 1.5 4418
1) Select P.TEL from T_PROSP P
where not singular (select PP.NUM from T_PROSP PP
where PP.TEL = P.TEL)
order by P.TEL
give correct result : all records with not unique TEL
but alas, as I can't chang the select clause I have to send :
2) Select T_PROSP.TEL from T_PROSP
where not singular (select PP.NUM from T_PROSP PP
where PP.TEL = T_PROSP.TEL)
order by T_PROSP.TEL
wich gave no result !
more strange
3) Select T_PROSP.TEL from T_PROSP
where 1 < (select count(*) from T_PROSP PP
where PP.TEL = T_PROSP.TEL)
order by T_PROSP.TEL
give all records! (and using an alias for first T_PROSP give correct
result)
except as using a stored proc with execute statement inside,
what coukd be the correct syntaxe to obtain what I need (records
having duplicate TEL) with an sql order starting with
select T_PROSP.TEL from T_PROSP
... my clause where
order by T_PROSP.TEL
thanks