sql - Getting Invalid use of group function for lengthy MySql query -


i've been trying query right when thought done , tried running it, error. i'm pretty sure line:

-> , sum(cr.file_size) > 5000000000

   select ss.title         -> ,sum(cr.file_size)         -> ,gr.user_id         -> ,ru.givenname         -> ,ru.sn         -> ,ru.mail         -> content_resource cr         -> ,sakai_site ss         -> ,sakai_realm_rl_gr gr         -> ,sakai_realm rl         -> ,rutgers_user ru         -> ,sakai_user_id_map map         -> cr.context = ss.site_id         -> , sum(cr.file_size) > 5000000000         -> , rl.realm_id = concat ('/site/',ss.site_id)         -> , rl.realm_key = gr.realm_key         -> , gr.role_key in (7,3)         -> , gr.user_id = map.user_id         -> , map.eid = ru.uid         -> outfile '/tmp/sitecontentusage.csv' fields terminated ',' enclosed '"' lines terminated '\n'; 

you need having clause. aggregation functions don't belong in where clauses:

having sum(cr.file_size) > 5000000000 

of course, presupposes have group by clause well, because having clause should go after group by. i'm not sure is, perhaps group user_id.

also, should learn proper explicit join syntax. simple rule: never use commas in from clause.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -