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 8863989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:07:35+00:00 2026-06-14T16:07:35+00:00

Sorry for the vague Title. I have a SQL Query SELECT SaleDate, Location, SUM(DollarSales)

  • 0

Sorry for the vague Title.

I have a SQL Query

SELECT SaleDate, Location, SUM(DollarSales)
FROM [TableName]
WHERE (SaleDate= '2012-11-19' OR SaleDate= '2012-11-12')
GROUP BY SaleDate, Location
ORDER BY Location, SaleDate

I get the results as follows

SaleDate                    Location    (No column name)
2012-11-12 00:00:00.000     002         21500.38
2012-11-19 00:00:00.000     002         24166.81
2012-11-12 00:00:00.000     016         14723.26
2012-11-19 00:00:00.000     016         12801.00

I want the results to look like

Location    (Sale on 11/12)    (Sale on 11/19)
002         21500.38           24166.81
016         14723.26           12801.00

I don’t want to use inner selects. Is there any way I can do this.
And this is on one of our legacy systems that uses SQL Server 2000.
Thank you in advance.

  • 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-14T16:07:36+00:00Added an answer on June 14, 2026 at 4:07 pm

    You could try:

    SELECT
    Location,
    SUM(CASE WHEN SaleDate = '2012-11-12' THEN DollarSales ELSE 0 END)'Sale on 11/12'
    SUM(CASE WHEN SaleDate = '2012-11-19' THEN DollarSales ELSE 0 END)'Sale on 11/19'
    FROM [TableName]
    GROUP BY Location
    ORDER BY Location
    

    This would only work if columns were static, you would have to change this if the dates change.

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

Sidebar

Related Questions

Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
Sorry the title is very vague. Basically, I'm stuck with something. I have an
Database: MS SQL 2008 SELECT Listing.Title, Listing.MLS, Pictures.PictureTH, Pictures.Picture, Listing.ID FROM Listing INNER JOIN
Sorry about the vague title but I have a servlet with the following mapping
sorry for the vague title... I have a problem with a php4 class that
I'm sorry for the vague title, I think you really have to see the
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
sorry for the vague title. I'm extracting some data from a table with the
Sorry for the vague, title! I have a website with a lot of PDF
Sorry if the title is a little vague, I have the following sceneraio: I

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.