Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Help writing a query

Author  Topic 

foutuguy
Starting Member

3 Posts

Posted - 2008-01-28 : 10:11:59
Hello,
I have a database containing 2 tables:
the first one called "weeks" has 4 columns: id, week number (ex:
2007/01), start date(ex:01/01/2007), end date(ex: 07/01/2007)
the second one is called "tests" and has 5 columns: index, date, name,
test name, duration

my goal: I want to make a query to get rows containing 3 columns:
week number,
name,
dates = date1, date2, etc.,
tests=test1, test2, etc.,
total duration of test for the given week and given person

To be clear, I am trying to get per week a summary of names with the
tests they did and how long total it lasted. The first tables is just
here to get the week number, given the test date.
My current query returns a list of all tests (table 2) with an added
column of the week number and looks like this:

SELECT date, initials, test, [hours outside 8-19], [Week number] FROM
tests, weeks WHERE date BETWEEN [start date] AND [end date]

What I need now is to have one line per person and per week with their total of hours for the week and the list of tests for the same week. I tried lots of things but does not know to get to my goal. Could
someone please help me?

Any help will be appreciated. Thank you in advance

Pierrot

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2008-01-28 : 10:15:38
is this schoolwork?
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-01-28 : 19:00:45
One approach to look at is using a calendar table.

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

foutuguy
Starting Member

3 Posts

Posted - 2008-01-29 : 02:07:30
It is no schoolwork.
I already have a query integrating the week number so my concern is more about grouping the result lines that have the same name and week number, adding the hours. Am I clear in my explanations?
Go to Top of Page
   

- Advertisement -