oracle sql not a group by expression while counting -


this question has answer here:

i'm trying run following query counts number of doctors patient referrals within last 6 months:

select      count(local_doc.providerno) numberofreferals,      local_doc.fullname fullname,      local_doc.telnumber telnumber,      local_doc.street street,      local_doc.suburb suburb,      local_doc.state state,      local_doc.postcode postcode,     local_doc.providerno      local_doc,      patient       patient.providerno = local_doc.providerno , patient.referaldate <= sysdate , patient.referaldate >= add_months(sysdate, -6)     group local_doc.providerno; 

i keep getting

ora-00979: not group expression 00979. 00000 -  "not group expression" *cause:     *action: error @ line: 3 column: 5 

and have no idea how around this. how so?

dear, group clause ask user specify select columns in group clause except select columns aggregated functions.

look in group clause have specify columns in select except local_doc.providerno because using aggregated function count

for better understanding please refer link

 select      count(local_doc.providerno) numberofreferals,      local_doc.fullname fullname,      local_doc.telnumber telnumber,      local_doc.street street,      local_doc.suburb suburb,      local_doc.state state,      local_doc.postcode postcode,     local_doc.providerno      local_doc,      patient       patient.providerno = local_doc.providerno , patient.referaldate <= sysdate , patient.referaldate >= add_months(sysdate, -6) group     local_doc.fullname ,      local_doc.telnumber ,      local_doc.street ,      local_doc.suburb ,      local_doc.state ,      local_doc.postcode ,     local_doc.providerno 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -