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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL select question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-15 : 09:23:48
mike writes "I have a table which keeps count of files that end up in a folder through out the day.
I have fields that record the time the files show up with some other information.

Here’s my question;

I need to wright a query to use in a report that shows a graph. This graph has to show how many files came in the folder in 15 minute intervals. With multiple queries I can get the information however I can’t graph it. So I think I might have to make a temp table and populate that and use that table to graph my results?

I just don’t know where to start?

Can any help?

Thanks
Mike "

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-15 : 10:10:51
you have to create a table of all intervals and then left join to that table.
your null rows will be those that have no files in the interval.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 10:12:03
Which 15 minute interval do you need?

00-14
15-29
30-44
45-59

Try this
SELECT		DATEADD(minute, 15 * FLOOR(DATEDIFF(minute, 0, FileTime) / 15), 0),
COUNT(*)
FROM FileTable
GROUP BY DATEADD(minute, 15 * FLOOR(DATEDIFF(minute, 0, FileTime) / 15), 0)
ORDER BY 1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -