我在MS-SQL Server上学起很难!
我想要MS-SQL Server的基本查询语句是全部!
在死记!在从中获取新的方法!让自己更快能学好!

解决方案 »

  1.   

    基本语句要撑握,比如:select ,from ,where ,left join ,right join,inner join ,group by ,
    order by ,having 等下面给你一个语句参考学习:
    elect d.cust_name as 客户,b.pdorder_no as 工令单号,c.passel as 批号,
    isnull(d2.type_name,'') as 石料名称, a.stone_id as 石号,a.stone_size as 规格, isnull(e.type_name,'') as 净度,
    isnull(f.type_name,'') as 颜色,isnull(g.type_name,'') as 形状,a.qty_prc as 数单价,a.wgt_prc as 重单价,
    sum(a.qty) as 数量,sum(a.wgt) as 重量,sum(isnull(a.qty,0)*isnull(a.qty_prc,0)+isnull(a.wgt,0)*isnull(a.wgt_prc,0)) as 金额,
    a.fromstone_no as 配石单号,convert(varchar(10),h.setstone_date,120) as 配石日期,a.re as 石头备注,
    isnull(a.metalin_no,'') as 采购单号
    from (select a.*,e.metalin_no
    from tbpdorder_stone a 
    left join 
    (select a.stone_no,a.stoneid,a.stonesize,a.grade,a.color,a.shape,
    dbo.fn_metalin_no(a.stone_no,a.stoneid,a.stonesize,a.grade,a.color,a.shape) as metalin_no
    from tbMetalIn_stone a inner join tbMetalIn b on a.metalin_no=b.metalin_no
    where isnull(b.addvalue,0)<>0 and a.qty>0
    group by a.stone_no,a.stoneid,a.stonesize,a.grade,a.color,a.shape
    )e on a.stone_no=e.stone_no and a.stone_id=e.stoneid and a.stone_size=e.stonesize and a.grade=e.grade and a.color=e.color and a.shape=e.shape 
    where a.qty_prc>0 or a.wgt_prc>0 or isnull(e.metalin_no,'')<>''
    )a
    left join tbpdorder b on a.barcode=b.barcode
    left join tborder c on b.order_no=c.order_no
    left join tbCustomer d on c.cust_no=d.cust_no
    left join tbset_dtl d2 on a.stone_no=d2.type_code and d2.type_no='Stone'
    left join tbset_dtl e on a.grade=e.type_code and e.type_no='Grade'
    left join tbset_dtl f on a.color=f.type_code and f.type_no='Color'
    left join tbset_dtl g on a.shape=g.type_code and g.type_no='Shape'
    left join tbsetstone h on a.fromstone_no=h.setstone_no
    group by d.cust_name,b.pdorder_no,c.passel,isnull(d2.type_name,''),
    a.stone_id,a.stone_size,isnull(e.type_name,''),isnull(f.type_name,''),isnull(g.type_name,''),a.qty_prc,a.wgt_prc,
    a.fromstone_no,convert(varchar(10),h.setstone_date,120),a.re,isnull(a.metalin_no,'')
      

  2.   

    上面刚开头字母应该是select,漏了首字母s在函数方面需要撑握的是:isnull(),convert(),substring(),charindex()等等
      

  3.   

    一个项目涉及到的50个Sql语句(整理版)
    http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html
      

  4.   

    学好有3点(个人意见)
    #1. 基本的语法相对简单,入门很快
    #2. 搞清楚每个SQL语句的查询原理,才能灵活,正确地运用
    #3. 投入 ^ ^
      

  5.   

    一个项目涉及到的50个Sql语句(整理版)
    http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html
      

  6.   

    sql基础并不多,很容易就能上手。
    比较难的是将这些语句灵活使用。
      

  7.   

    在学习一门课程知识之前要看看他在你所在的地方的需求,需求决定一切,我所在的城市(天津)很少需要这方面的人才了,DBA的话还是选oracle吧,Java和c#比起来还是Java需求多。。