Such as I have data
Id date
1001, 2019-10-11
2001 the 2016-01-02
3001 the 2015-03-04
1001 the 2013-02-02
1001 the 2018-03-05
6001 the 2017-05-06
3001 the 2018-03-06
2001 the 2019-05-06
Want to compare the same ID, the difference of each date, how to write, novice to teach,
CodePudding user response:
By top to bosses coach
CodePudding user response:
No one
to teach
CodePudding user response:
This mean?
SELECT id, The age (date, LAG (date, 1) OVER (PARTITION BY id ORDER BY date)) Time_interval The FROM lagtable; CodePudding user response:
reference minsic78 reply: 3/f this mean? SELECT id, The age (date, LAG (date, 1) OVER (PARTITION BY id ORDER BY date)) Time_interval The FROM lagtable; Teacher, you this lag function should be able to realize my needs, I also want to use the data step cycle to achieve there, just don't know how to use a pointer or other traverse each line, you this time_interval is stem what of CodePudding user response:
Didn't understand that "each line with a pointer or other traversal" is what's that mean? You want to use the cursor traverses the entire table? Which efficiency is too low, even with the cursor, you need to get a record will be very trouble before, may be more IO N times out, scan a full table analysis function can fix this thing, if you want the full table data to do this operation, if only one part of the data, then look at the situation) Time_interval is individual name, CodePudding user response:
reference 5 floor minsic78 reply: don't understand "use a pointer or other traverse each line" is what's that mean? You want to use the cursor traverses the entire table? Which efficiency is too low, even with the cursor, you need to get a record will be very trouble before, may be more IO N times out, scan a full table analysis function can fix this thing, if you want the full table data to do this operation, if only one part of the data, then look at the situation) Time_interval is individual name, Understand, I tried it once, it is not to use vernier sas, and the teacher, now there is a table in a field is 0 or 1, I want to know after a minus 0 (the previous 0 1) behind the poor, have what good algorithm or function CodePudding user response:
reference 5 floor minsic78 reply: don't understand "use a pointer or other traverse each line" is what's that mean? You want to use the cursor traverses the entire table? Which efficiency is too low, even with the cursor, you need to get a record will be very trouble before, may be more IO N times out, scan a full table analysis function can fix this thing, if you want the full table data to do this operation, if only one part of the data, then look at the situation) Time_interval is individual name, It says that is wrong, skip... CodePudding user response:
reference 5 floor minsic78 reply: don't understand "use a pointer or other traverse each line" is what's that mean? You want to use the cursor traverses the entire table? Which efficiency is too low, even with the cursor, you need to get a record will be very trouble before, may be more IO N times out, scan a full table analysis function can fix this thing, if you want the full table data to do this operation, if only one part of the data, then look at the situation) Time_interval is individual name, I want to say is, a date and a list of fields is 0 or 1, the date is discrete, I want to know the date of the succession of 15 1 (days), have what good method?