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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:21:09+00:00 2026-05-24T22:21:09+00:00

How can I group my results in a query such as this: SELECT (

  • 0

How can I group my results in a query such as this:

SELECT (
             SELECT SUM(wky) FROM table
             WHERE Earnings_Date BETWEEN '2011-08-14' AND '2011-08-16'
            ) +
            (SELECT SUM(earnings) FROM table
            WHERE Earnings_Date BETWEEN '2011-08-14' AND '2011-08-16') / .75

The above query returns wky+(earnings/.75) for all the sites (each site has a wky and earnings number for different dates. Where would I put a group by in the above query? I would like my results to be grouped by site_id, since the above query just returns the sum of the earnings of all of them.

Thanks!

  • 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-05-24T22:21:10+00:00Added an answer on May 24, 2026 at 10:21 pm
    SELECT site_id, (SUM(wky) + (SUM(earnings) / 0.75)) 
    FROM Earnings_Date
    WHERE Earnings_Date BETWEEN '2011-08-14' AND '2011-08-16'
    GROUP BY site_id
    

    Your data comes from the same table for both queries, so you can combine them.

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

Sidebar

Related Questions

Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
Let's consider such query: SELECT * FROM ( SELECT YEAR(OrderDate) [Year], MONTH(OrderDate) [Month], SubTotal
Consider This Query: SELECT [Order Details].OrderID, c.CategoryName, COUNT(c.CategoryID) FROM [Order Details] INNER JOIN Products
I can persist an object into the DB from Java as such: Table Person:
SELECT k.condition, SUM(IIf(AnimalType=3,1,0)) AS Carnivore, SUM(IIf(AnimalType=4,1,0)) as Herbivore From Animals a inner join knownconditions
SELECT EmployeeMaster.EmpNo, Sum(LeaveApplications.LeaveDaysTaken) AS LeaveDays FROM EmployeeMaster FULL OUTER JOIN LeaveApplications ON EmployeeMaster.id =
I have a fairly complex query that looks something like this: create table Items(SomeOtherTableID
I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM
I have to write a query to database, that has such table: TABLE HISTORY:
I have a query such that the query's result is: SELECT CONVERT(VARCHAR(8),(MAX(END_TIME)-MIN(START_TIME)),108) as DURATION

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.