group by problem

Started by Shiby Thomasabout 28 years ago3 messageshackers
Jump to latest
#1Shiby Thomas
sthomas@cise.ufl.edu

Hi,

I get the foll. error for a group by query:
This is with the snapshot of Feb 20, and I am running on sparc-solaris 2.6

insert into FTemp1 select item as item1, count(*) as cnt from data group by
item;
ERROR: The field being grouped by must appear in the target list

Thanks
--shiby

#2Bruce Momjian
bruce@momjian.us
In reply to: Shiby Thomas (#1)
Re: [HACKERS] group by problem

Hi,

I get the foll. error for a group by query:
This is with the snapshot of Feb 20, and I am running on sparc-solaris 2.6

insert into FTemp1 select item as item1, count(*) as cnt from data group by
item;
ERROR: The field being grouped by must appear in the target list

Thanks
--shiby

Say:

group by item1.

--
Bruce Momjian
maillist@candle.pha.pa.us

#3Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#2)
Re: [HACKERS] group by problem

=> > insert into FTemp1 select item as item1, count(*) as cnt from data group by
=> > item;
=> > ERROR: The field being grouped by must appear in the target list
=> >
=> > Thanks
=> > --shiby
=>
=> Say:
=>
=> group by item1.
It works.
=>
But, just wanted to check this also.
I get the same error for:
insert into FTemp1 select item, count(*) as cnt from data group by item
also.

So, is it mandatory now to give alias names for all the selected columns if
we are using group by

No, I am sorry. Looks like we have a bug where GROUP BY can't be used
with INSERT ... SELECT.

--
Bruce Momjian
maillist@candle.pha.pa.us