2017-10-18 55 views

回答

0

我有使用子查詢

以下解決方案
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 
+0

這是行不通的,因爲它不是一個sql訪問c#程序訪問(它將與SQL服務器一起工作) – Fawzidi