Solved

How can i fix this query?

Posted on 2011-02-28
5
299 Views
Last Modified: 2012-05-11

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
Comment
Question by:checkmofoshoduno
5 Comments
 
LVL 18

Assisted Solution

by:Cluskitt
Cluskitt earned 250 total points
ID: 34995938
SELECT S_NUM, SUM(S_PHQ)
FROM      ORDER
GROUP BY S_NUM
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 34995945
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
 

Author Comment

by:checkmofoshoduno
ID: 34995947
Whats wrong with the first query?
0
 

Author Comment

by:checkmofoshoduno
ID: 34995951
Got it, thankk you
0
 
LVL 3

Expert Comment

by:mehdi_javan
ID: 34995971
You can't have aggregation function with a simple field in a select statement without "group by". This is a rule.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now