Wrox Programmer Forums
|
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
 
Old July 15th, 2005, 11:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accummulated Man-Hours

How can calculate the Employees ACCUMMULATED MAN-HOURs ?

Tables structure like this.

CREATE TABLE [dbo].[BH] (
[RECID] [int] IDENTITY (1, 1) NOT NULL ,
[DATED] [smalldatetime] NULL ,
[EMPNO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PROJNO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[BH] [int] NULL ,
[USERID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[MH1] (
[RECID] [int] IDENTITY (1, 1) NOT NULL ,
[DATED] [smalldatetime] NULL ,
[EMPNO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PROJNO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[MH1] [int] NULL ,
[USERID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO



CREATE TABLE [dbo].[EMP] (
[RECID] [int] IDENTITY (1, 1) NOT NULL ,
[EMPNO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[NAME] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[USERID] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[POSIT] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DEPTCODE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DEPT] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO



CREATE TABLE [dbo].[DEPT] (
[RECID] [int] IDENTITY (1, 1) NOT NULL ,
[DEPTCODE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[DEPT] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO


Data in table (MH1) like this.

empno....projno……mh1……dated…….Accummul atedHours
---------------------------------------------------
012125…240……...10………1/6/2005
012125….240……..10………1/13/2005
012125….240……..10………1/20/2005
012125….240……..10………1/27/2005………..40

012125…240….…..10………2/3/2005
012125….240……..10………2/10/2005
012125….240……..10………2/17/2005
012125….240……..10………2/24/2005………80


012125…240……. 10……….3/3/2005
012125….240……..10………3/10/2005
012125….240……..10………3/17/2005
012125….240……..10………3/24/2005
012125….240……..10………3/31/2005……….130
....
... and so on....

cont end of year..


Data in BH (Budgeted Hour) table like this.

Empno…..BH…..projno…..
------------------------
012125…..200…..240
012125…..170…..233
012125…..200…..967
….
..


Simple Data insert in MH1 table
-----------------------------

insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'1/6/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'1/13/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'1/20/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'1/27/2005','martin')

insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'2/3/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'2/10/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'2/17/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'2/24/2005','martin')


insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'3/3/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'3/10/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'3/17/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'3/24/2005','martin')
insert into mh1 (projno,empno,mh1,dated,userid)
values ('240','06367',10,'3/31/2005','martin')


Table BH
-----------
insert into BH (projno,empno,BH,userid)
values ('240','06367',200,'martin')

insert into BH (projno,empno,BH,userid)
values ('223','06367',170,'martin')

insert into BH (projno,empno,BH,userid)
values ('967','06367',200,'martin')
....
….

EMP TABLE
-----------
insert into emp (empno,name,userid)
values ('06367',’Martin’,'martin')
insert into emp (empno,name,userid)
values ('02323',’Peter’,'peter')
insert into emp (empno,name,userid)
values ('02424',’Jones’,'jones')

Dept table
------------
insert into dept (dept)
values ('Account')
insert into dept (dept)
values ('High Way')
insert into dept (dept)
values ('Transportation')
….



(Accummulated column not in table)

How can retrieve the data from above tables like this.
Result.

Project No.240
Empno… Name….Detp …….BH…..totalHours...Accumulated MH1………MH1.dated
------------------------------------------------------------------------
06367….Martin..Account 200……….40………….40…………. ….…… 1/27/2005
06367….Martin..Account 170……….40………….80………………†¦.…12/24/2005
06367….Martin…Account 200………50………….130…………….…⠀¦.12/31/2005
….
……..
And so on……

MH1=Man-hours
BH=Budgeted Hours
Totalhours=total month hour
Date= month end date (MH1)


Data retrieved base on MH1.dated how ?
what query will use.

Please help.

regards























Similar Threads
Thread Thread Starter Forum Replies Last Post
How to subtract hours from sysdate in oracle mcmouli Oracle 4 January 7th, 2011 06:52 AM
Procedure or function STOREDPROC has too man rit01 ASP.NET 2.0 Basics 4 January 25th, 2006 09:51 AM
Calculating hours and minutes between to dates timmaher Access VBA 4 May 10th, 2005 07:36 AM
java.sql.SQLException: [Microsoft][ODBC Driver Man pvsharinath@gmail.com Java Databases 1 May 5th, 2005 02:40 AM
9 hours later still trying to do a login script sand133 VB.NET 2002/2003 Basics 5 June 24th, 2004 10:26 AM





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