标签 WITH AS 文章列表

假如我们有个分组查询的需求,要求按照指定字段进行分组并同时查询出分组字段的第一条和最后记录,大致数据如下: UNION查询1: SELECT 1 AS ID, 110 AS TRAIN_ID UNION SELECT 2 AS ID, 111 AS TRAIN_ID UNION SELECT 3 AS ID, 112 AS TRAIN_ID UNION查询2: SELECT 110 AS TRAIN_ID , 1 AS ID,1...

SQL Server 2015-12-14 768浏览 0评论 喜欢(9)