bsimmons01@gmail.com wrote:[color=blue]
> Hi All,
>
> I'm completely green to DB2, so please pardon my ignorance if this is
> an extremely easy question.[/color]
Don't worry. We'll make you blue.[color=blue]
> Here's the query (part of it):
> SELECT a.org_lc || b.oros_rsrc || 'M' as ref_no, b.activity_desc,
> sum(a.org_bud_amt)
> FROM ab.vbudget_r01 a, ab.vabc_rsrc_xref b,
> WHERE a.gl_yr = 2005 and a.id = b.id
> GROUP BY ref_no, b.activity_desc[/color]
Makes sense ref_no is not available within the query.[color=blue]
>
> It doesn't like the ref_no in the Group-By and I tried "a.org_lc ||
> b.oros_rsrc || 'M' " in there as well, and it didn't like that either.[/color]
That's odd. what is the error mesage you get and which version/platform
of DB2 are you on:
Here is what I get (DB2 Viper, but should work since at least DB2 UDB V5
for LUW):
db2 => create table TTT(c1 varchar(10), c2 varchar(20), c3 INT)@
DB20000I The SQL command completed successfully.
db2 => select c1 || c2 || 'M', c3 FROM TTT GROUP BY c1 || c2 || 'M', c3@
1 C3
------------------------------- -----------
0 record(s) selected.[color=blue]
> I tried GROUP 1, 2 and it didn't like that either.[/color]
That's correct. Allowing column numbers in ORDER BY was a mistake to
begin with.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab