[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can i fix this query?

Posted on 2011-02-28
5
Medium Priority
?
352 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 1000 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 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

649 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