Computing.Net > Forums > Database > Query for SQL Database

Query for SQL Database

Reply to Message Icon

Original Message
Name: Mathijn75
Date: June 28, 2007 at 05:28:33 Pacific
Subject: Query for SQL Database
OS: Windows XP
CPU/Ram: XEON 2.4
Model/Manufacturer: DELL
Comment:

I have the following table and I want the difference for each Product/Process combination to the next process. The next process is not fixed, so it is necessary that the next timestamp is selected.
A difference has to be calculated between two rows, which will be the result of a calculated field.
It would be nice if the query has 2 parameters: Product and Process

Product |Proces |TimeStamp
1 |heat |28-6-2007 14:17
2 |heat |28-6-2007 16:06
1 |cool |28-6-2007 23:51
2 |cool |29-6-2007 2:10
1 |warm |29-6-2007 3:02
2 |warm |29-6-2007 7:55

Required Result of the Query:

Product|Proces| Time Difference to next[hr]
1 |heat | 9,57
1 |cool | 0,13
2 |heat | 0,42
2 |cool | 0,24

I tried several things but it was not succeeding. Is there someone who can help me?


Report Offensive Message For Removal


Response Number 1
Name: pingy
Date: July 3, 2007 at 13:16:06 Pacific
Subject: Query for SQL Database
Reply: (edit)

SQL can't look ahead so basically you'll have to make a program. Witch tool/language you use is depending on the brand/type of database you're using.

If, in this particular case, there are only two timestamps per Product|Proces you could make a query for the minimum timestamp and one for the maximum timestamp per Product|Proces, join the two and calculate the difference.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Query for SQL Database

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge