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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:13:45+00:00 2026-06-15T08:13:45+00:00

I have a SQL statment that I am trying to pull the sum for

  • 0

I have a SQL statment that I am trying to pull the sum for all JobTypes, for example, if there are 5 Jobs with the name “Process” they should show up on only one line with the Sum for the GB and KB. How do I accomplish this? Thanks.

so i would show: – jpavlov 10 mins ago
DEC 1, 2012, Data Extrat, sum(60), sum(56) – jpavlov 8 mins ago
DEC 1, 2012, Process, sum(60), sum(56)

   SELECT 

Jobs.DateCompleted  AS 'DateCompleted',
JobTypes.Name AS 'JobName',
SUM(Metrics.GB) AS GB, 
SUM(Metrics.KB) AS KB
FROM Metrics 

INNER JOIN
Jobs ON Jobs.JobId = Metrics.JobId 
INNER JOIN

Projects ON Projects.ProjectId = Jobs.ProjectId 

INNER JOIN
JobTypes ON JobTypes.JobTypeId = Jobs.JobTypeId

WHERE Jobs.DateCompleted 
Between '12/01/2012' AND '12/03/2012' 

GROUP BY  
Jobs.DateCompleted, 
JobTypes.Name

2012-12-01 04:28:15.477 Data Extract    0.200   210903.738
2012-12-01 04:40:07.913 Data Extract    0.781   819388.602
2012-12-01 04:48:45.493 Data Extract    5.278   5538731.844
2012-12-01 04:54:55.483 Data Extract    6.927   7265870.682
2012-12-01 14:11:38.357 Export  13.189  13828648.369
2012-12-01 16:57:54.840 Process 2.054   2156185.331
  • 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-15T08:13:46+00:00Added an answer on June 15, 2026 at 8:13 am

    Remove CAST (Jobs.DateCompleted AS VARCHAR(MAX)) From the SELECT as well as GROUP BY.

    Assumption: JobTypes.Name and JobTypes.JobTypeId has 1 to 1 mapping.

    EDIT

    SELECT 
    JobTypes.Name AS 'JobName',
    SUM(Metrics.GB) AS GB, 
    SUM(Metrics.KB) AS KB
    FROM Metrics 
    
    INNER JOIN
    Jobs ON Jobs.JobId = Metrics.JobId 
    INNER JOIN
    
    Projects ON Projects.ProjectId = Jobs.ProjectId 
    
    INNER JOIN
    JobTypes ON JobTypes.JobTypeId = Jobs.JobTypeId
    
    WHERE Jobs.DateCompleted 
    Between '12/01/2012' AND '12/03/2012' 
    
    GROUP BY  
    JobTypes.Name
    

    For the result to get summed up by Name field, you will have to remove the DateCompleted from Select as well as Group By.

    EDIT2:

    Take a look at this question and modify your sql.

    SELECT 
    convert(varchar(10), Jobs.DateCompleted, 120) AS DateCompleted
    JobTypes.Name AS 'JobName',
    SUM(Metrics.GB) AS GB, 
    .....
    .....
    GROUP BY  
    convert(varchar(10), Jobs.DateCompleted, 120),
    JobTypes.Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sql statement that concatenates two columns, ItemNumber and Name, into one
I have an sql statement that currently is just returning all the end parent
I have a perplexing SQL select statement (ugly) that I'm trying to write in
I have a SQL Statement that I am trying to convert to a LINQ
I have a query in SQL Server that I am trying to convert to
I have the following sql statement - it's trying to find all the zipcodes
I have been trying to pull all infomation where $user is equal to subscriberID
I have a sql statement that uses Difference => http://msdn.microsoft.com/en-us/library/ms188753.aspx I do this in
I have an SQL statement that I'm executing through OleDb, the statement is something
I have an sql statement that is supposed to return 2 rows. the first

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.