Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to show zero values in conditional sums

I am trying to write a SQL statement to pull some data into an Excel
(2007)spreadsheet from our SQL Server (2005). In essence I am trying to
manipulate the same column twice. The only way I know how to do this is to
create two SQL queries. The problem is that the number of rows do not match.
Can I show zero values for items that do not meet the conditions?

I am trying to show total time entered into our timesheet program vs total
billable time for a given period.

Here are the queries

To show BILLABLE TIME:

SELECT EMPLOYEE, SUM(TOTAL) AS BILLABLE
FROM TRANS
WHERE (DATE CONVERT(DATETIME, '2007-06-01 00:00:00', 102))
AND (DATE < CONVERT(DATETIME, '2007-07-01 00:00:00', 102))
AND (BILLABLE = 'T')
GROUP BY EMPLOYEE
ORDER BY EMPLOYEE

To show TOTAL TIME:
SELECT EMPLOYEE, SUM(TOTAL) AS BILLABLE
FROM TRANS
WHERE (DATE CONVERT(DATETIME, '2007-06-01 00:00:00', 102))
AND (DATE < CONVERT(DATETIME, '2007-07-01 00:00:00', 102))
GROUP BY EMPLOYEE
ORDER BY EMPLOYEE


Thanks for your help...

Jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to show zero values in conditional sums

"JMillians (beginner)" wrote:

I am trying to write a SQL statement to pull some data into an Excel
(2007)spreadsheet from our SQL Server (2005). In essence I am trying to
manipulate the same column twice. The only way I know how to do this is to
create two SQL queries. The problem is that the number of rows do not match.
Can I show zero values for items that do not meet the conditions?

I am trying to show total time entered into our timesheet program vs total
billable time for a given period.

Here are the queries

To show BILLABLE TIME:

SELECT EMPLOYEE, SUM(TOTAL) AS BILLABLE
FROM TRANS
WHERE (DATE CONVERT(DATETIME, '2007-06-01 00:00:00', 102))
AND (DATE < CONVERT(DATETIME, '2007-07-01 00:00:00', 102))
AND (BILLABLE = 'T')
GROUP BY EMPLOYEE
ORDER BY EMPLOYEE

To show TOTAL TIME:
SELECT EMPLOYEE, SUM(TOTAL) AS BILLABLE
FROM TRANS
WHERE (DATE CONVERT(DATETIME, '2007-06-01 00:00:00', 102))
AND (DATE < CONVERT(DATETIME, '2007-07-01 00:00:00', 102))
GROUP BY EMPLOYEE
ORDER BY EMPLOYEE


Thanks for your help...

Jeff


Sorry for the typo in the original message - the second query actually
begins with
SELECT EMPLOYEE, SUM(TOTAL) AS TOTAL
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I ge tmy sum to show the + sign for positive sums? Karie Excel Worksheet Functions 2 May 15th 09 06:52 PM
Help - Conditional Sums Dave B New Users to Excel 5 January 16th 09 07:54 PM
Conditional sums GTIGUY Excel Worksheet Functions 1 May 21st 08 12:47 PM
Conditional Sums Peter J Elliott New Users to Excel 5 February 17th 07 08:22 AM
conditional sums Randy[_11_] Excel Programming 0 May 12th 04 10:21 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"