zoukankan      html  css  js  c++  java
  • Sql Server cross apply和outer apply

    with result as(
    select t.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    union all
    select '5' str
    union all
    select '6' str
    union all
    select '7' str
    ) t
    cross apply
    (select t2.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    ) t2
    where t.str = t2.str) t3)
    select * from result;
    go
    
    with result as(
    select t.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    union all
    select '5' str
    union all
    select '6' str
    union all
    select '7' str
    ) t
    outer apply
    (select t2.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    ) t2
    where t.str = t2.str) t3)
    select * from result;
    go
    
    select t.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    union all
    select '5' str
    union all
    select '6' str
    union all
    select '7' str
    ) t
    cross apply
    (select t2.str from(
    select '1' str
    union all
    select '2' str
    union all
    select '3' str
    union all
    select '4' str
    ) t2
    where t.str = t2.str) t3;
    go
    2015年10月-2016年3月 总计:5个月.
    2016年11月-2017年6月 总计:7个月.
    2017年7月-2018年4月 总计:9个月.
    2018年5月-2018年5月 总计:1个月.
    2018年6月-2018年12月 总计:6个月.
    2019年1月-2019年12月 总计11个月.
    2020年2月-2021年2月 总计13个月.
    所有总计:5+7+9+1+6+11+13=52个月(4年4个月).
    本人认同二元论.我是理想主义者,现实主义者,乐观主义者,有一定的完美主义倾向.不过,一直都是咸鱼(菜鸟),就算有机会,我也不想咸鱼翻身.(并不矛盾,因为具体情况具体分析)
    英语,高等数学,考研,其他知识学习打卡交流QQ群:946556683
  • 相关阅读:
    Fedora安装ati显卡驱动
    [转]SQLite 3入门教程
    [转]QT:不规则窗口的实现
    Ubuntu 10.10可用源
    [转]Qtopia2.2.0移植
    [转]嵌入式Qtopia2.2.0开发环境的搭建和使用
    ES6 find 和 filter 的区别
    “/ArcGIS/rest”应用程序中的服务器错误——解决办法
    Java:String和Date、Timestamp之间的转换
    UVA 100 The 3n+1 Problem
  • 原文地址:https://www.cnblogs.com/JimmySeraph/p/10550769.html
Copyright © 2011-2022 走看看