x

How many hours did consultant Janet Park work in each of her projects

CONSULTANT C_ID C_LAST C_FIRST C_MI C_ADD C_CITY C_STATE C_ZIP C_PHONE C_EMAIL 100 Myers Mark F 10 Sky Blvd. Orlando FL 32825 4075551212 mm@xx.com 101 Hernandez Sheila R 33 Left Cr. Orlando FL 32811 4071115555 sh@yyx.com 102 ZHANG Brian 89 SE Ave. Tampa FL 32822 3211515555 bz@mm.org 103 Carlson Sarah J 22 NW Pl. Orlando FL 32825 4075111111 sc@uu.gov 104 Courtland Paul R 91 Water St. Orlando FL 32800 4075151155 pc@pp.net 105 Park Janet S 15 High Rd. Miami FL 32816 9541115555 jp@hr.net

PROJECT_CONSULTANTS P_ID C_ID ROLL_ON_DATE ROLL_OFF_DATE TOTAL_HOURS 1 101 06/15/2008 12/15/2008 175 1 104 01/05/2008 12/15/2008 245 1 103 01/05/2008 06/05/2008 50 1 105 01/05/2008 12/15/2008 45 2 105 07/17/2008 09/17/2008 25 2 100 07/17/2008 09/17/2002 0 3 103 09/15/2008 03/15/2009 125 3 104 10/15/2008 12/15/2008 50 4 105 06/05/2008 06/05/2009 25 4 104 06/15/2008 12/15/2008 125 4 102 07/15/2008 12/15/2008 30 5 105 09/19/2008 03/19/2009 15 5 103 09/19/2008 03/19/2009 15 6 103 09/19/2008 03/19/2009 5 6 104 09/19/2008 03/19/2009 10 7 102 05/20/2008 12/20/2008 125 7 100 05/25/2008 12/20/2008 100
more ▼

asked Mar 24, 2010 at 12:42 PM in Default

Michael 4 gravatar image

Michael 4
9 9 9 9

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Your question could be better laid out, but something along the lines of:

select c.c_id, p_id, sum(total_hours) as total_hours
from consultant c
    join project_consultants p on p.c_id = c.c_id
where c.c_id = 105         -- or c.c_first = 'Janet' etc?
group by c.c_id, p.p_id

Dave.

more ▼

answered Mar 24, 2010 at 02:23 PM

user-1392 gravatar image

user-1392
71 1

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x371
x75

asked: Mar 24, 2010 at 12:42 PM

Seen: 1160 times

Last Updated: Mar 24, 2010 at 06:03 PM