• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

How can i fix this query?


I need to know why the following command would create an error, and what could be changed to fix the error:

SELECT S_NUM, SUM(S_PHQ)
FROM      ORDER;
0
checkmofoshoduno
Asked:
checkmofoshoduno
2 Solutions
 
CluskittCommented:
SELECT S_NUM, SUM(S_PHQ)
FROM      ORDER
GROUP BY S_NUM
0
 
Carl TawnSystems and Integration DeveloperCommented:
You need to have a GROUP BY clause so that the query knows which fields to sum together.

Try it as:
SELECT S_NUM, SUM(S_PHQ)
    FROM ORDER
    GROUP BY S_NUM

Open in new window

0
 
checkmofoshodunoAuthor Commented:
Whats wrong with the first query?
0
 
checkmofoshodunoAuthor Commented:
Got it, thankk you
0
 
mehdi_javanCommented:
You can't have aggregation function with a simple field in a select statement without "group by". This is a rule.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now