0

Please, help me with query:

SELECT 
    N.site_name, 
    Count(N.site_name), 
    SUM (IF((SC.type_conn = 'GET') && (SC.type_conn = 'CONNECT'),N.size_site,0)) as Traffic_IN, 
    SUM (IF(SC.type_conn = 'POST',N.size_site,0)) as Traffic_OUT 
From 
    news N, 
    status_conn SC, 
    users U 
where 
    N.id_conn = SC.id_conn and 
    N.id_user = U.id_user and 
    U.name_user = 'max' and 
    N.date_conn = '2015-08-04' 
Group by 
    N.site_name 
Order by 
    SUM (IF((SC.type_conn = 'GET') && (SC.type_conn = 'CONNECT'),N.size_site,0))
8
  • 2
    Please don't use this type of JOINs, And clarify us about how can we help you?! ;). Commented Aug 4, 2015 at 7:21
  • What kind of help do you need ? Any specific error ? Commented Aug 4, 2015 at 7:29
  • function SUM don`t work, maybe i have mistake in query?? Commented Aug 4, 2015 at 7:34
  • But what is your error message ? Commented Aug 4, 2015 at 7:37
  • ERROR : #1630 FUNCTION [name_db].sum does not exist. Check the ' Function Name Parsing and Resolution' action in the Reference Manual Commented Aug 4, 2015 at 7:59

2 Answers 2

1

I don't know witch is the problem; in any case you could try this:

Select N.site_name, 
Count(N.site_name), 
SUM (IF((SC.type_conn = 'GET') && (SC.type_conn = 'CONNECT'),N.size_site,0)) as Traffic_IN, 
SUM (IF(SC.type_conn = 'POST',N.size_site,0)) as Traffic_OUT 
From news N, status_conn SC, users U
where N.id_conn = SC.id_conn 
and N.id_user = U.id_user 
and U.name_user = 'max' 
and N.date_conn = '2015-08-04' 
Group by N.site_name 
Order by Traffic_IN

otherwise

select ...
...
Order by 3
Sign up to request clarification or add additional context in comments.

Comments

0

You may very well have a parenthesis problem at the end of your query. Try

[...] ORDER BY SUM (IF((SC.type_conn = 'GET') && (SC.type_conn = 'CONNECT')),N.size_site,0)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.