By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,610 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,610 IT Pros & Developers. It's quick & easy.

db2 select & group by

P: 1
Hi,

Can anyone suggest - what are the alternative means I achieve following functionality -

select x , y from table1 group by x

since rules say group by clause needs all listed fields in select clause. Forgive me for if the question is to naive. Thanks
Sep 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: 1
Hi Monica,

Suppose your table looks like
create table test(t1 number, t2 number, t3 number)

Use temporary table tb for selecting columns that are in group by as

select ta.t1, ta.t2, tt from test ta, (select t1, sum(t3) as tt from
test group by t1) tb
where ta.t1 = tb.t1

Neelu


QUOTE=monicaj]Hi,

Can anyone suggest - what are the alternative means I achieve following functionality -

select x , y from table1 group by x

since rules say group by clause needs all listed fields in select clause. Forgive me for if the question is to naive. Thanks[/quote]
Sep 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.