db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta Satoor" <msat...@gmail.com>
Subject Re: What's the name of a column...
Date Wed, 14 Nov 2007 16:55:05 GMT
The column name for the first column of select MAX(idstat) would be
'1'. I tried following in ij and it shows what is the column name
assigned when the query has aggregate functions.

ij> create table t1(c11 int, c12 int);
0 rows inserted/updated/deleted
ij> select max(c11), max(c12) as col1 from t1;
1          |COL1
-----------------------
NULL       |NULL
1 row selected
ij> select max(c11), max(c12)  from t1;
1          |2
-----------------------
NULL       |NULL
1 row selected
ij> select max(c11) as col1, max(c12)  from t1;
COL1       |2
-----------------------
NULL       |NULL
1 row selected

On 11/14/07, Mark Thornton <mthornton@optrak.co.uk> wrote:
> Luis Angel Fernandez Fernandez wrote:
> >   Hi!
> >
> >   I execute a query like this: select MAX(idstat) from history;
> >
> >   Now, from the ResultSet, how can I get the data by column name?
> >
> >   Using rs.getString() with idstat, MAX(idstats)... I get column not
> > found. There is an idstat field. What's the name for that kind of
> > columns? I did some searches with no success.
> >
> >   Bye!
> >
> That column doesn't have a name unless you write the query as something like
>
> select MAX(idstat) as "maxIdStat" from history
>
> Regards
> Mark Thornton
>
>

Mime
View raw message