Solved

How can i fix this query?

Posted on 2011-02-28
5
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

707 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