Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 29th, 2005, 08:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Group by , Sub Group by and Sum

How can calculate the sum of Man hours work end of week.
With group by projectno and sub group by dept

query is

SELECT BHOURS.BHOUR, MHOURS.NAME, MHOURS.PROJNO, MHOURS.DEPT, MHOURS.MHOURS
FROM BHOURS INNER JOIN MHOURS ON BHOURS.EMPNO = MHOURS.EMPNO;


TABLE BUDGETED HOUR
--------------------
empno ..varchar
name….varchar
dept….varchar
projno..varchar
bhour..nvarchar


TABLE MAN HOUR
------------------
empno varchar
name varharh
dated smaldatetime
projno varchar
dept….varchar
mhours..nvarchar

Please help to create query group by project no and sub group by
dept no ?

sum of each dept no man hour work ?



PROJECT NO. C2016
--------------------------------------------------
DEPT....NAME....BUDGETED MHOUR...MAN HOUR
---------------------------------------------------
HIGHWAY
........BULENT....170............17
........MARTIN....200............7

STRUCTURE
........ASOKAN....196............40
........STREETON..344............130
...
...




reagrds.

Mateen


  #2 (permalink)  
Old March 29th, 2005, 09:51 AM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

*******Posted by Robvolk********************
Take a look in Books Online under "CUBE" and "ROLLUP". You may also want to look at "COMPUTE BY", but it is harder to work with and may be dropped in future releases of SQL Server. And it is usually better to perform multiple summarizations in a report rather than in a query.
********************************




Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I in SQL group by week & sum the values (i.e. callagga SQL Language 2 May 16th, 2008 07:25 AM
sum group values based on cell criteria darkdestroyer Excel VBA 1 January 9th, 2008 09:13 PM
Sum a column at the group level? srussell705 SharePoint Development 0 October 3rd, 2007 08:40 AM
SUM and GROUP BY in vba wdepreter Excel VBA 3 February 5th, 2007 06:11 AM
GROUP BY Avg and Sum pinkandthebrain SQL Server 2000 3 July 14th, 2003 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.