zoukankan      html  css  js  c++  java
  • Sql递归关联情况,With作为开头条件。

    with Test_Recursion(Id,ParentId)
    AS
    (
    select Id,ParentId  from [V_KPI_DetailsActivities] where ParentId  = 4 --没有引用CTE自身必须放在第一个递归行之上
    union all  --没有引用CTE自身的语句和第一个递归行之间必须用UNION ALL
    select a.Id,a.ParentId from [V_KPI_DetailsActivities] as a join Test_Recursion as b on a.parentid=b.id--递归行

    select Id into #temp from Test_Recursion;
    select row_number() over (order by id ) as rowid,*  from [V_KPI_DetailsActivities] where ProjectId=13
    and ID   = 4 or ID in (select Id  from #temp )
    drop table #temp;

  • 相关阅读:
    python 模块包裹
    函数指针
    python界面
    python FileError
    python pickle
    python file
    python set
    python 字典的函数
    字典问题
    java学习笔记4
  • 原文地址:https://www.cnblogs.com/szlixin/p/4212815.html
Copyright © 2011-2022 走看看