【问题标题】:SQL Access query first date and last date for each series (c#.net)SQL Access查询每个系列的第一个日期和最后一个日期(c#.net)
【发布时间】:2017-10-18 08:58:30
【问题描述】:

我需要为每个系列选择第一个日期和最后一个日期

【问题讨论】:

    标签: c# sql ms-access


    【解决方案1】:

    我有以下使用子查询的解决方案

    select t1.person_id,
           t1.date as start_date,
           (
              select max(date) 
              from your_table t2
              where t2.date > t1.date and t2.date < ALL(
                         select date 
                         from your_table t3 
                         where t3.first = 1 and t3.date > t1.date)
           ) as end_date
    from your_table t1
    where t1.first = 1
    

    【讨论】:

    • 这不起作用,因为它不是具有访问权限的 c# 程序的 sql 查询(它将与 sql server 一起使用)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 1970-01-01
    • 2012-05-29
    相关资源
    最近更新 更多