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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:26:04+00:00 2026-06-14T21:26:04+00:00

I have a table that goes like this: Now i’m trying to get all

  • 0

I have a table that goes like this:
my db
Now i’m trying to get all called columns and a sum of the duration for a specific called var.
Now i’m trying this :

select called,SUM(duration) as dursum,time,CONVERT(VARCHAR(8), time, 4) AS Batch  
from Calls
where caller='somevalue'
group by called,time
order by called

Now the problem is that i guess because i order by time as well i don’t really get distinct values by called, i get the same number several times, and ofcourse the sum acts the same, sums only part of the rows.

I can’t remove the group by time as it will cause an error for using the SUM function.

Again i want the result to have every called number once per day and the dursum to contain all the duration sum and grouped by the batch column somehow…

How can i solve this?

  • 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-14T21:26:05+00:00Added an answer on June 14, 2026 at 9:26 pm

    You are right, not grouping by time brings you the correct resultset. However, the error occuring then is easily explainable: it is caused by the selection of ” time,CONVERT(VARCHAR(8), time, 4) AS Batch ” in the select clause -> thus you just need some kind of aggregation for the time-field (for instance MAX(time),CONVERT(VARCHAR(8), MAX(time), 4) AS Batch.

    Best regards

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

Sidebar

Related Questions

Say I have a table that goes clockwise like this: 2 1 3 0
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL
I have a table that looks like this: ID (pk,int) Col1 (nvarchar) Col2 (nvarchar)
I have a class that goes like this: public static class Messenger<T> { private
I have a procedure that goes like this: create or replace PROCEDURE NEWJOBIDPROC (JOB_ID
I have a variable that I got out of the database table like this:
I have a Conditions table that looks like this : Conditions ConditionID MappingID VariableID
I have a table that acts as a dropbox for files that get automatically
I have a situation and it goes like this: I need to print out

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.