zoukankan      html  css  js  c++  java
  • just some skills for SQL

    1 about the name regulation for table,store procedure,view ..    
          normally, each different kind of object should be named with specific flag, such as table named as Tab_*, store procedure named as Pr_*, view named as V_*,....
     
    2 use sql scripts to populate some query scripts, such as     
        eg. there are many tables, which are named as ds_in_*, then we wanna check each table and its record count concerned. we can write the following scripts:
        select
    'select ''' + name + ''', count(*) from ' + name            
        from sys.objects        
        where type = 'U'        
        and name like 'ds_in%'
    then result will be    
        select ds_in_bom,count(*) from ds_in_bom
        select ds_in_..,count(*) from ds_in_*...

    3 when write some query scripts, we should put the "," before each field, not behind each field
     eg.
        select a    
                ,b
                ,c
                ,d
        from table
        where
            a=*&^**    
            and b=**&....

     

    4. duplicated select example:
        e.g 1
          
      select CurCust.Name
                    ,CurCurst.Discount
                    (
                        select Avg(AvgCust1.Discount)
                        from Customer AvgCust1
                        where Curcurst.ShipCity=AvgCust1.ShipCity
                     )
                        as CityAvg
                    ,Curcust.Discount/
                    (
                        select Avg(AvgCust2.Discount)
                        from Customer AvgCust2
                        where CurCust.shipcity=AvgCust2.shipcity
                    )
                        as timesCityAvg
                from Customer CurCust

        e.g.2

    select 
             (select studentname from student where student.studentno=sc.studentno) as 学生姓名
             ,studentno as 学生学号
             ,avg(score) as 个人平均成绩
             ,(select avg(score) from sc) as 全班平均成绩
             , case 
                  when avg(score) >(select avg(score) from sc) then 'better than avg'
                  else 'worse than average'  
                end
                as 评价
    from sc
    group by studentno

                

  • 相关阅读:
    jQuery
    jquery获得内容
    获得链接中 href 属性的值
    遍历及过滤 first(), last() 和 eq() filter() 和 not()
    siblings() next() nextAll() nextUntil() prev() prevAll() prevUntil() 在 DOM 树中水平遍历
    后代children() find()的区别
    parent() parents() parentsUntil()三者之间的对比
    拿到类名为two_data的里面自定义属性为data的值为14的话,就给这行代码在添加一个class等于active的类
    动态给某一个元素添加active
    Jquery中拿到相同的对应的所有的标签
  • 原文地址:https://www.cnblogs.com/Winston/p/1048944.html
Copyright © 2011-2022 走看看