Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7900407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:57:47+00:00 2026-06-03T08:57:47+00:00

I really couldn’t figure out a good title for this question, but I have

  • 0

I really couldn’t figure out a good title for this question, but I have a problem that I’m sure you can help me with!

I have a query which outputs something like this:

Month | Year | Subcategory | PrivateLabel | Price
-------------------------------------------------
  1   | 2010 | 666         | No           | -520
  1   | 2010 | 666         | No           | -499,75
  1   | 2010 | 666         | No           | -59,95
  1   | 2010 | 666         | No           | -49,73
  1   | 2010 | 666         | No           | -32,95

I want to SUM on the price because all the other data is the same. I thought I could do this with SUM and GROUP BY, but I can’t figure out how to do it or at least it doesn’t output the right result.

The query is an inner join between two tables, if that helps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:57:49+00:00Added an answer on June 3, 2026 at 8:57 am
    select
       month
       ,year
       ,subcategory
       ,privatelabel
       ,sum(price) as [total sales]
    from
       a inner join b ...
    where
       any where clauses 
    group by
       month
       ,year
       ,subcategory
       ,privatelabel
    

    should work if i am understanding you correctly.. every colum in the select either needs to be part of the group by or an aggregate function on all rows in the group

    added a fiddle.. mainly as i didn’t know about he text to DDL functionality and wanted to test it 😉 (thanks Michael Buen)

    http://sqlfiddle.com/#!3/35c1c/1

    note the where clause is a place holder..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe it's easy, but I couldn't really figure this out right so far... I
sorry, I know this question might be too common, but I really couldn't figure
Sorry for the title, I really couldn't think of how to simplify this problem.
I've been thinking of this question very long, but really couldn't find the answer
I couldn't really word the title very well, but here's my problem: I've got
Though this question has been asked several times but I really couldn't find any
I have this htaccess code RewriteRule ^/([uge])/([^/]+)$ /$1/$2/ But I couldn't really understand what
My sincere apologies if this question has been asked, but I really couldn't find
OK, so I couldn't really think of an apropos title that summarizes this. The
I tried searching, but I couldn't really figure out the best search terms to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.