|
|
-
Group by clause gives error
yogesh.kumar13@... 2012-08-10, 06:53
Hi all,
I have a dummy table having values date name type ------------------------------ 01 x a 01 y a 01 z b 02 u c 02 x d 03 t a I want to operate operation that
count the name and type on the same date and order by date.
I wrote this query
select date, count(*), name from demotable group by date;
its throws error:
Error in semantic analysis: Expression not in GROUP BY key 'name' (Although this query works in Mysql ) Please suggest
Thanks & Regards Yogesh Kumar Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
+
yogesh.kumar13@... 2012-08-10, 06:53
-
Re: Group by clause gives error
MiaoMiao 2012-08-10, 08:12
You need to apply an aggregate function to NAME since it's not used as a GROUP BY key.
Without an aggregate function, your query will be confusing. I mean, what does `select name from sometable group by date;` mean anyway?
Try
select date, count(type), count(name) from demotable group by date; On Fri, Aug 10, 2012 at 2:53 PM, <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a dummy table having values > > > date name type > ------------------------------ > 01 x a > 01 y a > 01 z b > 02 u c > 02 x d > 03 t a > > > I want to operate operation that > > count the name and type on the same date and order by date. > > I wrote this query > > select date, count(*), name from demotable group by date; > > its throws error: > > Error in semantic analysis: Expression not in GROUP BY key 'name' > (Although this query works in Mysql ) > > > Please suggest > > Thanks & Regards > Yogesh Kumar > > > > > > Please do not print this email unless it is absolutely necessary. > > The information contained in this electronic message and any attachments to > this message are intended for the exclusive use of the addressee(s) and may > contain proprietary, confidential or privileged information. If you are not > the intended recipient, you should not disseminate, distribute or copy this > e-mail. Please notify the sender immediately and destroy all copies of this > message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient should > check this email and any attachments for the presence of viruses. The > company accepts no liability for any damage caused by any virus transmitted > by this email. > > www.wipro.com
+
MiaoMiao 2012-08-10, 08:12
|
|
All projects made searchable here are trademarks of the Apache Software Foundation.
Service operated by
Sematext