Home » SQL & PL/SQL » SQL & PL/SQL » Multiple fields with allongside COUNT
Multiple fields with allongside COUNT [message #227634] Wed, 28 March 2007 19:30 Go to next message
respon
Messages: 3
Registered: March 2007
Junior Member
Hi,

I am trying to add more fields to my SELECT statement when using the COUNT(*) function as well. The following query works fine;

SELECT worker, COUNT(*) FROM workerskills GROUP BY worker;

This gives me a list of the workers... and if they appear more than once in that table, this will be totalled and shown in the next column labelled COUNT. My issue is i want to display more than just 'worker'... i am trying to bring in more details from another table.. and if i put;

SELECT address, worker, COUNT(*) FROM workerskills, workers GROUP BY worker;

I get a GROUP BY error. ERROR at line 1: ORA-00979: not a GROUP BY expression indicating the other fields i am trying to include in the output. Am i approaching this in the wrong way?

Re: Multiple fields with allongside COUNT [message #227635 is a reply to message #227634] Wed, 28 March 2007 19:39 Go to previous messageGo to next message
respon
Messages: 3
Registered: March 2007
Junior Member
Ah, nevermind i have got it. I need to include all of the SELECT fields in the GROUP BY field.
Re: Multiple fields with allongside COUNT [message #227717 is a reply to message #227635] Thu, 29 March 2007 02:59 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Thanks for the feedback.

http://www.orafaq.com/forum/fa/448/0/

Closed.

MHE
Previous Topic: Conditional Query
Next Topic: Force View
Goto Forum:
  


Current Time: Fri Dec 09 23:16:58 CST 2016

Total time taken to generate the page: 0.09246 seconds