我的目标是GROUP (eid) SORT BY dayatime()
,在每组中选择前两次,计算一天的差异。
我知道这个想法,但我怎么能把它翻译成真正的MySQL查询语法?
mysql> select * from events;
+------+------------+
| eid | dt |
+------+------------+
| 1 | 2013-01-01 | -> 3
| 1 | 2013-01-04 | -> 1
| 1 | 2013-01-05 |
| 2 | 2013-04-01 | -> 7
| 2 | 2013-04-08 |
+------+------------+
5 rows in set (0.00 sec)
GOAL: query that gives this result:
+------+------------+-----------------+
| eid | dt | days_until_next |
+------+------------+-----------------+
| 1 | 2013-01-01 | 3 |
| 1 | 2013-01-04 | 1 |
| 2 | 2013-04-01 | 7 |
答案 0 :(得分:1)
基本上,您需要$0 ~ text { # run these commands if we find your text
getline stn <"inp1" # read a new input line from the file "inp1"
sub(/insert_text/,stn) # do the substitution.
}
1 # shorthand for "print the current line".
功能,但MySQL不支持此功能。相反,您可以使用相关子查询:
Schedule(() => Console.WriteLine("This task will run at last day of every month."))
.ToRunEvery(1)
.Months()
.OnTheLastDay();