| Author |
Topic |
|
djorre
Yak Posting Veteran
94 Posts |
Posted - 2009-06-21 : 09:06:44
|
| Hi friends,I got a question and simplified it for you:I need to get from this table:id value1 02 1 3 14 05 0 6 0 7 18 0 9 010 011 012 113 114 115 116 0To this Query:2 17 112 1The id column is in reality a timestamp column and the Value column is a proximity switch.The 'switching' time can differ and the time between switches can differ too. How?Please help,Greetings Joris |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-21 : 09:31:40
|
[code]declare @sample table (xid int, xvalue int)insert @sampleselect 1, 0 union allselect 2, 1 union allselect 3, 1 union allselect 4, 0 union allselect 5, 0 union allselect 6, 0 union allselect 7, 1 union allselect 8, 0 union allselect 9, 0 union allselect 10, 0 union allselect 11, 0 union allselect 12, 1 union allselect 13, 1 union allselect 14, 1 union allselect 15, 1 union allselect 16, 0--select * from @sampleselect s1.xid, s1.xvaluefrom @sample as s1join @sample as s2 on s2.xid = s1.xid-1 and s1.xvalue = 1 and s2.xvalue = 0[/code] No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
djorre
Yak Posting Veteran
94 Posts |
Posted - 2009-06-21 : 09:42:12
|
| Yes Thank you only the next problem is that in reality id is not id but it is a random timestamp... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-21 : 09:51:19
|
Can you show example data? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
djorre
Yak Posting Veteran
94 Posts |
Posted - 2009-06-21 : 10:03:01
|
| I got it thank you very much, the time stamp has sampling interval of near 0.2 secondsthis is my code select cast(s1.thetime as datetime), s1.opbrengst from LabJackLog...Logging#csv as s1 join LabJackLog...Logging#csv as s2 on round(s2.thetime*24*60*60,1) = round(s1.thetime*24*60*60,1)-0.2 and s1.opbrengst = 1 and s2. opbrengst = 0thanks all |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-21 : 10:27:03
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
djorre
Yak Posting Veteran
94 Posts |
Posted - 2009-06-27 : 12:38:45
|
Well it was working until today I want to add the water sensor.I made a screenshot because I do not understand what is wrong,normally it should log every 0 to 1 flansh, but as you can see sometimes it doesnt: Does anyone understand why this isen't logged? |
 |
|
|
djorre
Yak Posting Veteran
94 Posts |
Posted - 2009-06-27 : 13:41:45
|
| ok i put the -0.2 inside the () and was ok... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-27 : 18:00:33
|
fine  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|