Subject | Re: Nested Select |
---|---|
Author | Svein Erling Tysvær |
Post date | 2004-11-05T07:12:03Z |
<Just adding to what Ann answered>:
I think this actual select may be rewritten as
SELECT t1.risk, COUNT(distinct t1.name)
FROM Table1 t1
where not exists(
select * from Table1 t2
where t2.name = t1.name
and t2.risk > t1.risk)
GROUP BY t1.risk
Though of course there could be other situations that cannot be solved by simply
rewriting the query a little bit.
HTH,
Set
I think this actual select may be rewritten as
SELECT t1.risk, COUNT(distinct t1.name)
FROM Table1 t1
where not exists(
select * from Table1 t2
where t2.name = t1.name
and t2.risk > t1.risk)
GROUP BY t1.risk
Though of course there could be other situations that cannot be solved by simply
rewriting the query a little bit.
HTH,
Set
--- In firebird-support@yahoogroups.com, "Ann W. Harrison" wrote:
> At 05:59 AM 11/4/2004, jabangarita wrote:
>
> >How does Firebird/Interbase nested select work in??
> >
> >SELECT t.risk, COUNT(t.name)
> >FROM [SELECT t1.name, MAX(t1.risk) as risk
> > FROM Table1 AS t1
> > GROUP BY t1.name ]. AS t
> >GROUP BY t.risk;
>
> Firebird 1.5 and earlier don't handle select from select.
> Firebird 2 does, but uses ISO syntax that does not
> include square brackets. For earlier versions, turn
> the inner select into a view or use a stored procedure.
>
> Regards,
>
> Ann