Subject Re: SQL question
Author Ali Gökçen
Ops! sorry,
you can't select more than one column in subselects.

-Ali

--- In firebird-support@yahoogroups.com, Ali Gökçen <alig@e...>
wrote:
> Hi Michael,
> As you know, there is no row# limit about your group but
> tables and selects have column# limit.
>
> Anyway,
> You can turn your rows 90 degree with some ways if u sure about
> group limit..
>
> Select
> (select First 1 ty,sum(amount) from test group by ty) as GROUPSUM1,
> (select First 1 skip 1 ty,sum(amount) from test group by ty) as
> GROUPSUM2,
> from rdb$database
>
> ( i didn't test it but worked theorically in my untheareded single
> proccessed brain ;) )
>
> or you can write a selectable stored procedure and suspend
> rows as columns..
>
> Regards,
>
> -Ali
>
> --- In firebird-support@yahoogroups.com, "Michael Vilhelmsen"
> <Michael.Vilhelmsen@M...> wrote:
> > Hi
> >
> > Lets say I have a table defined as:
> >
> > CREATE TABLE TEST (
> > TY INTEGER,
> > AMOUNT NUMERIC(15,2) DEFAULT 0);
> >
> > If this contains this:
> >
> > 0,100
> > 1,200
> > 0,200
> > 1,300
> > 0,300
> >
> > An SQL statement like
> >
> > Select
> > ty,
> > SUM(Amount)
> > from Test
> > Group by
> > ty
> >
> > gives me this:
> >
> > 0,600
> > 1,500
> >
> >
> > Can I make an SQL that returns something like this:
> >
> > 600,500
> >
> > In short - I would like to have both SUM returned on the same
> line...
> >
> >
> > Regards
> > Michael