我记得数据库SQL语句中在输出时候,可以分组
好像是“co..... by”控制
记不清楚了
求高手帮忙回忆这个,并解释下

解决方案 »

  1.   

    group by
    order by 
      

  2.   

    select a,
    sum(b) as b,
    max(c) as c
    from tb group by a
      

  3.   

    楼主朋友,分组的关键字是 group by.如果想对分组进行选择可以加上having关键字.
    举个例子,选出某班级里年龄是20岁,人数多余3人的学生组
    select 
        年龄
        ,count(学生ID)
    from
        学生表
    where
        年龄=20
    group by
        年龄
    having 
        count(学生ID)>3
      

  4.   

    不是group by
    group by只是分组
    我说的那个是输出的时候物理上分组输出
    例如  姓名   性别
    输出:  
    A     M
    ---------
    B     M这样物理输出上分组我记得原来看见过,用的太少,不记得了
      

  5.   

    SQL Server2005高端培训视频,循序渐进,历时半年通过3大分系列的46次课程,让你完全掌握SQL Server2005.
    同Visual Studio 2005以及Microsoft .NET集成的开发特性,通过实例由浅入深的帮助您掌握这些看似难懂的技术。
    http://auction1.taobao.com/auction/item_detail-0db2-512881e1a3aab7111ccf190b0068536d.jhtml
      

  6.   

    group by ... with cube/rollup  ??
      

  7.   

    Category            Shortened Title           Price                      
    ------------------- ------------------------- -------------------------- 
    Business            You Can Combat Computer S 2.99                       
    Business            Cooking with Computers: S 11.95                      
    Business            The Busy Executive's Data 19.99                      
    Business            Straight Talk About Compu 19.99                                                                    avg
                                                  ==========================
                                                  13.73                      Category            Shortened Title           Price                      
    ------------------- ------------------------- -------------------------- 
    Modern Cooking      The Gourmet Microwave     2.99                       
    Modern Cooking      Silicon Valley Gastronomi 19.99                                                                    avg
                                                  ==========================
                                                  11.49                      Category            Shortened Title           Price                      
    ------------------- ------------------------- -------------------------- 
    Popular Computing   Secrets of Silicon Valley 20.00                      
    Popular Computing   But Is It User Friendly?  22.95     需要通过查询达到这样的效果~group by做不到吧?不用CASE,group by,做的到吗?