在sql查询中每15分钟提取一次数据

时间:2015-09-14 16:27:34

标签: sql-server

SELECT dateadd(MINUTE,datediff(MINUTE,-15,Time),15) AS Time,
       round(avg(Amount),1) AS Amount,
       round(avg(Amount2),1) AS Amount2
INTO downt
FROM ee3
JOIN ee4 
     ON DownLine1=DownLine2 --Where Time Null
GROUP BY datediff(MINUTE, -15,Time)
ORDER BY time DESC;

SELECT *
FROM downt;

所以我有一个点,我能够每30分钟提取和分组数据。但我的问题是为什么这个查询不能每15分钟给我一次数据?我提供的脚本是一个较大的脚本的一部分,它只是运行一个存储过程,它提供的时间戳只是localtimestamp。上面的脚本可以完成所有工作。

enter image description here

1 个答案:

答案 0 :(得分:0)

here借一点,并假设我理解你的问题,我建议如下:

    # RESET PRO
url(
    r'^mdp-lost-pro/$',
    auth_views.password_reset,
    {
        'template_name': 'pro/login/mdp-lost.html',
        'html_email_template_name': 'emails/password_reset_email_pro.html',
        'post_reset_redirect': 'password_reset_done',
    },
    name='password_reset_pro'
),
url(
    r'^mdp-lost-pro-ok/$',
    auth_views.password_reset_done,
    {'template_name': 'pro/login/mdp-lost-ok.html'},
    name='password_reset_done'
),
url(
    r'^mdp-reset-pro/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
    auth_views.password_reset_confirm,
    {
        'template_name': 'pro/login/mdp-reset-confirm.html',
        'post_reset_redirect': 'password_reset_complete',
    },
    name='password_reset_confirm'
),
url(
    r'^mdp-reset-pro-ok/$',
    auth_views.password_reset_complete,
    {'template_name': 'pro/login/mdp-reset-done.html'},
    name='password_reset_complete'
),

# RESET PATIENT
url(
    r'^mdp-lost-patient/$',
    auth_views.password_reset,
    {
        'template_name': 'patient/login/mdp-lost.html',
        'html_email_template_name': 'emails/password_reset_email_patient.html',
        'post_reset_redirect': 'password_reset_patient_done',
    },
    name='password_reset_patient'
),
url(
    r'^mdp-lost-patient-ok/$',
    auth_views.password_reset_done,
    {
        'template_name': 'patient/login/mdp-lost-ok.html',
    },
    name='password_reset_patient_done'
),
url(
    r'^mdp-reset-patient/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
    auth_views.password_reset_confirm,
    {
        'template_name': 'patient/login/mdp-reset-confirm.html',
        'post_reset_redirect': 'password_reset_patient_complete',
    },
    name='password_reset_patient_confirm'
),
url(
    r'^mdp-reset-patient-ok/$',
    auth_views.password_reset_complete,
    {'template_name': 'patient/login/mdp-reset-done.html'},
    name='password_reset_patient_complete'
),