Forum Moderators: open
[caseID] **Int**
[Type] **Int**
[SubType] **Int**
[time] **datetime**
This table just logs information where the first column just logs the id of a certain case, the next 2 columns the type and subtype of the event, and the time column logs when that event has happened for that case.
For example you can have:
1 0 0 "12/04/08 12:35:00"
1 0 1 "12/04/08 12:39:00"
1 1 2 "12/04/08 12:51:00"
2 0 0 "12/04/08 12:35:20"
2 1 2 "15/04/08 16:12:20"
Is it possible to do some statistical calculations on that table using the rows, for example, calculating the average time it takes to go between type and subtype 0,0 to type and subtype 1,2?
I know you can calculate average and such between columns but being new to SQL I am not sure where to start in a case like this where rows are what I am using.
Any input is welcome.
What I need is basically, be able to take AVG((SELECT column A WHERE column B=X) - (SELECT column A WHERE column B=Y)).
Is this doable? Basically taking the difference of 2 values which are in different rows but share a common value (Like ID column) and then do an AVG for that difference over all different IDs.