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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:03:02+00:00 2026-05-24T20:03:02+00:00

First of all, execuse the longer question, but I will try to put it

  • 0

First of all, execuse the longer question, but I will try to put it as simply as possible…

I’m trying to write a kind of a reporting query, but I’m having a problem getting the desired results. The problem:

Employee table

Id   |   Name                   
---------------
1    |   John Smith
2    |   Alan Jones
3    |   James Jones

Task table

Id   |   Title   |   StartDate   |   EmployeeId  |  Estimate (integer - ticks)
----------------------------------------------------------------------------
1    |   task1   |   21.08.2011  |   1           |   90000000000
2    |   task2   |   21.08.2011  |   1           |   150000000
3    |   task3   |   22.08.2011  |   2           |   1230000000

Question:

How to get the estimate summary per day, grouped, but to include all the employees?

Like this:

Date           |   EmployeeId   |   EmployeeName    |    SummaryEstimate
 -------------------------------------------------------------
19.08.2011     |   1            |   John Smith      |    NULL
19.08.2011     |   2            |   Alan Jones      |    NULL
19.08.2011     |   3            |   James Jones     |    NULL
20.08.2011     |   1            |   John Smith      |    NULL
20.08.2011     |   2            |   Alan Jones      |    NULL
20.08.2011     |   3            |   James Jones     |    NULL
21.08.2011     |   1            |   John Smith      |    90150000000
21.08.2011     |   2            |   Alan Jones      |    NULL
21.08.2011     |   3            |   James Jones     |    NULL
22.08.2011     |   1            |   John Smith      |    NULL
22.08.2011     |   2            |   Alan Jones      |    1230000000
22.08.2011     |   3            |   James Jones     |    NULL

What I currently do is I have a “dates” table with 30years of days. I left join and group by that table to get other dates included too. Well, here is the query:

  SELECT  dates.value, employee.Id, employee.Name, sum(task.Estimate)

  FROM TableOfDates as dates
  left join Tasks as task on (dates.value = convert(varchar(10), task.StartTime, 101))
  left join Employees as employee on (employee.Id = task.EmployeeId)

  WHERE dates.value >= '2011-08-19' and dates.value < '2011-08-22'

  GROUP BY dates.value, employee.Id, employee.Name

  ORDER BY dates.value, employee.Id

The convert call is to get the date part of the DateTime column.

The result that I get is:

Date           |   EmployeeId   |   EmployeeName    |    SummaryEstimate
 -------------------------------------------------------------
19.08.2011     |   NULL         |   NULL            |    NULL
20.08.2011     |   NULL         |   NULL            |    NULL
21.08.2011     |   1            |   John Smith      |    90150000000    
22.08.2011     |   2            |   Alan Jones      |    1230000000

I am there half of the way, I get dates that are not in the two base joined tables (Employees and Tasks) but I cannot also have all the employees included as in the table shown before this one.

I’ve tried cross-joining, then subqueries, but little luck there. Any help would be very much appreciated ! Thank you for having the time to go through all of this, I hope I was clear enough…

  • 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-24T20:03:03+00:00Added an answer on May 24, 2026 at 8:03 pm
    SELECT DE.DateValue, DE.EmployeeId, DE.EmployeeName, sum(task.Estimate)
    
    FROM 
    (  SELECT
         D.value AS DateValue
       , E.Id AS EmployeeId
       , E.Name AS EmployeeName
       FROM
       TableOfDates D      
       CROSS JOIN Employees E ) DE
    left join Tasks as task on DE.DateValue = convert(varchar(10), task.StartTime, 101)
      AND DE.EmployeeId = task.EmployeeId
    
    WHERE DE.DateValue >= '2011-08-19' and DE.DateValue < '2011-08-22'
    
    GROUP BY DE.DateValue, DE.EmployeeId, DE.EmployeeName
    
    ORDER BY DE.DateValue, DE.EmployeeId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all there is a partial question regarding this, but it is not
First of all, forgive me if this is a weird question, but it clear
First of all, excuse my poor topic title. I simply have no idea how
First of all, I know how to build a Java application. But I have
First of all: I am not an experienced ClearCase user, but I have lots
First of all, let's define a few tables: Users table will store information about
First of all excuse me for my english. This is my first question here.
First of all, I will admit I am a novice to web services, although
First of all, this is a follow up to a previous question of mine
Possible Duplicate: What's the difference between Invoke() and BeginInvoke() First of all, I would

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.