Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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


Reply With Quote
  #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.
********************************


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


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



All times are GMT -4. The time now is 07:36 PM.


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