CTE Tree

;with Tree as

(

select wjgl_20_col_10 as ID, wjgl_20_col_30 as Name,wjgl_20_col_60 as Parent from wjgl_20

where WJGL_20_COL_50=1 and (WJGL_20_COL_70 is null or WJGL_20_COL_70=1) and WJGL_20_COL_100=1

)

,CTE as

(

-->Begin 一个定位点成员

select ID, Name,Parent,cast(‘已发布文件/‘+Name as nvarchar(max)) as TE,0 as Levle from Tree where Parent=‘0‘

-->End

union all

-->Begin一个递归成员

select Tree.ID, Tree.Name,Tree.Parent,cast(CTE.TE+‘/‘+Tree.name as nvarchar(MAX)) as TE,Levle+1 as Levle

from Tree inner join CTE

on Tree.Parent=CTE.ID

-->End

)

select * from CTE order by TE

时间: 2024-12-29 23:59:27

CTE Tree的相关文章

SQL Server 2005中的CTE递归查询得到一棵树

感觉这个CTE递归查询蛮好用的,先举个例子: [c-sharp] view plain copy print ? use City; go create table Tree ( ID int identity(1,1) primary key not null, Name varchar(20) not null, Parent varchar(20) null ) go insert Tree values('大学',null) insert Tree values('学院','大学') i

分类树测试用例设计工具:CTE XL

1.1工具安装 CTE XL是一款免费的分类树测试用例设计工具,安装过程很简单,下载好安装程序后,运行安装程序:如图点击下一步:点击下一步:是否创建桌面按钮:安装:  安装完成后,需要注册才能获取免费的License,打开CTE XL,会弹出一个注册的对话框,输入好Firstname,Famliyname,Organization,Email后系统将会发送一封带License的邮件到填写的email地址上,获取后,复制到license key中就完成注册了 1.2 CTE XL的使用 在了解CT

SQLServer2005中的CTE递归查询得到一棵树

最近研究了一下CTE递归查询,感觉这个CTE递归查询蛮好用的,在网上找到了一个比较好的例子,测试例子如下 1 use City; 2 go 3 create table Tree 4 ( 5 ID int identity(1,1) primary key not null, 6 Name varchar(20) not null, 7 Parent varchar(20) null 8 ) 9 go 10 insert Tree values('大学',null) 11 insert Tree

easyui js取消选中 Tree 指定节点

取消所有选中 var rootNodes = treeObject.tree('getRoots'); for ( var i = 0; i < rootNodes.length; i++) { var node = treeObject.tree('find', rootNodes[i].id); treeObject.tree('uncheck', node.target); }

Maximum Depth of Binary Tree

这道题为简单题 题目: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 思路: 我是用递归做的,当然也可以用深搜和广搜,递归的话就是比较左右子树的深度然后返回 代码: 1 # Definition for a binary tre

538. Convert BST to Greater Tree 二叉搜索树转换为更大树

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Example: Input: The root of a Binary Search Tree like thi

SPOJ375 Query on a tree

https://vjudge.net/problem/SPOJ-QTREE 题意: 一棵树,每条边有个权值 两种操作 一个修改每条边权值 一个询问两点之间这一条链的最大边权 点数<=10000 多组测试数据,case<=20 Example Input: 1 3 1 2 1 2 3 2 QUERY 1 2 CHANGE 1 3 QUERY 1 2 DONE Output: 1 3 #include<cstdio> #include<iostream> #include&

POJ 1741 Tree(树的点分治,入门题)

Tree Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21357   Accepted: 7006 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001).Define dist(u,v)=The min distance between node u and v.Give an in

命令-tree

tree命令 tree - list contents of directories in a tree-like format. 显示目录的层级结构: tree 命令英文理解为树的意思,其功能是创建文件列表,将目录所有文件以树状的形式列出来.linux中的tree命令默认并不会安装,所以需要通过yum install tree -y来安装此命令. [SYNOPSIS] tree [options] [directory] [OPTIONS] -L level:指定要显示的层级: -d:仅列出目