Sql-server Database query help

Posted by menacheb on Stack Overflow See other posts from Stack Overflow or by menacheb
Published on 2010-04-22T08:27:01Z Indexed on 2010/04/22 8:33 UTC
Read the original article Hit count: 162

Filed under:
|
|

Hi,

I have a problem that I didn't manage to solve for a very long time, and I quite desperate.

I have a Database (SQL Server) with table named 'ProcessData' and columns named 'Process_Name' (Data Type: nvarchar(50)), 'Start_At' (DataType: DateTime) and 'End_At' (Data Type: DateTime).

I need to know for each 'Time-Interval' (let's say 1 minute) how many processes (Process_Name = PN) was open (after or equal to the 'Start_at' column and before or equal to the 'End_At' column) during this time (It can be a few rows with the same data).

Does anyone know how to make this query without a 'for' loop? (It ITSELF will promote the time), (The answer will be a table with two columns (1. The time the check took place. 2. the number of open processes at this time.) and a row for each 'Time-Interval' (1 minute in this example )

Many thanks,

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about database