zoukankan      html  css  js  c++  java
  • SQL samples

    ----------------query aggregation function and group by -------------------------


    SELECT Test1.Test, avg(Test1.Id) As avg, SUM(Test1.Id) As SUm, COUNT(Test1.Id) As Count FROM [Test1]


    GROUP BY Test1.Test


    HAVING count(Test1.Id)< 3



    ---- Query data from multiply data tables----use select in------------------------


    select Test1.Id, Test1.Test from Test1 where Test1.Id in


    (select Test2.Id from Test2 where Test2.Name in (select Test3.Name from Test3 where Test3.Description = 'D2'))



    ---- Query data from multiply data tables----use with------------------------


    with ba as ( select Test1.Id As Aid, Test2.Id As BID, Test2.Name from Test1 inner join Test2 on Test1.Id = Test2.Id )



    select

    * from ba



    ---- Query data from multiply data tables----------------------------


    select

    * from  (select Test.BID, Test3.Description from


    (

    select Test1.Id As Aid, Test2.Id As BID, Test2.Name from Test1 inner join Test2 on Test1.Id = Test2.Id where Test1.Id = 1) Test


    inner join Test3 on Test.Name = Test3.Name ) Test3333



    select Test1.Id As Aid, Test2.Id As BID, Test2.Name from Test1 inner join Test2 on Test1.Id = Test2.Id where Test1.Id = 1


    select * from Test2


    select * from Test3

    做个快乐的自己。
  • 相关阅读:
    js浏览器对象
    js对象
    js基础
    css的常见操作
    css 盒子模型
    css定位与浮动
    汇编三(习题)
    pyEcharts安装及使用指南(最新)
    pyEcharts安装及使用指南
    Anaconda安装第三方库与pip和conda 添加国内源
  • 原文地址:https://www.cnblogs.com/Jessy/p/2176126.html
Copyright © 2011-2022 走看看