我有一个SQL列的值像
PT2M52.37S
PT21.79S
PT53M29.68S
P
PT9S
Run Code Online (Sandbox Code Playgroud)
某些MySQL函数可以将上述格式转换为秒吗?
我已经搜索了所有内容,但没有找到与上述格式完全相同的格式。我尝试的任何日期mysql函数均无法正常工作。
有关此格式的更多信息:http : //www.ostyn.com/standards/scorm/samples/ISOTimeForSCORM.htm
PHP函数(始终为P,第一个字符)
function scorm_format_duration($duration) {
// Fetch date/time strings.
$stryears = get_string('years');
$strmonths = get_string('nummonths');
$strdays = get_string('days');
$strhours = get_string('hours');
$strminutes = get_string('minutes');
$strseconds = get_string('seconds');
if ($duration[0] == 'P') {
// If timestamp starts with 'P' - it's a SCORM 2004 format
// this regexp discards empty sections, takes Month/Minute ambiguity into consideration,
// and outputs filled sections, discarding leading zeroes and any format literals …Run Code Online (Sandbox Code Playgroud) 我搜索了很多关于此的不同帖子,但没有找到适合我的东西。
这在 GROUP BY 中使用 LIMIT 来获得每组 N 个结果?和http://www.sqlines.com/mysql/how-to/get_top_n_each_group对我不起作用。
我有一个简单的 MySQL 表,其中包含以下列
id , package, user_id, date
Run Code Online (Sandbox Code Playgroud)
我想执行一个查询,我将得到
X 行 / user_id WHERE 日期 > 编号 按日期 ASC 排序
简而言之,我们想要执行Group By user_idwithLIMIT of X rows / group但要记住使用 the 的语句date column
全表示例:
id , package, user_id, date
1, full, 1 , 1447003159
2, full, 1 , 1447003055
3, full, 1 , 1447002022
4, full, 1 , 1447001013
5, full, 1 , …Run Code Online (Sandbox Code Playgroud)