仪器社区

SQL with xx as 编号

不撸大弟 2018-03-12
WITHMakeModuleNoAS(SELECT''ASLEVEL_,c.*FROMTABLE_NamecWHEREc.Guid_=@PnGuidUNIONALLSELECT''ASLEVEL_,c.*FROMTABLE_NamezINNERJOINTABLE_NamecONz.Guid_=c.Guid4ChKB)为每一级查询... WITH MakeModuleNo AS ( SELECT '' AS LEVEL_,c.* FROM TABLE_Name c WHERE c.Guid_ = @PnGuid UNION ALL SELECT '' AS LEVEL_,c.* FROM TABLE_Name z INNER JOIN TABLE_Name c ON z.Guid_ = c.Guid4ChKB ) 为每一级查询编一个数字代号,同一级的拥有同一个编号
评论
全部评论
39703zzsjx
示例代码如下:

;with a as(select * from table_a),
b as (select * from a where id in(3,4,5))
select * from b

记得一定要有逗号间隔开两个查询,Z后一个查询前是没有逗号的
12 0 2018-03-13 0条评论 回复
您可能感兴趣的社区主题
加载中...
发布 评论