select * from qktable where qk_class=2

解决方案 »

  1.   


    Select A.* from qktable A
    Inner Join (Select qk_Name,Max(qk_djq) As qk_djq from qktable Where qk_class=2 Group By qk_Name) B
    On A.qk_Name=B.qk_Name And A.qk_djq=B.qk_djq
      

  2.   

    --楼主不厚道, 答题问题不给分.
    --测试数据
    if object_id('qktable') is not null drop table qktable
    go
    create table qktable(qk_Name varchar(10), qk_gjissn varchar(10)
    , qk_djq int, qk_class int, qk_img varchar(10))insert qktable select  '中国海关', '100-67083', 1, 2, '1.jpg'
    union    all   select  '中国海关', '100-67083', 2, 2, '2.jpg'
    union    all   select  '市场营销', '100-67082', 5, 2, '3.jpg'
    union    all   select  '电子商务', '100-58830', 1, 2, '4.jpg'
    union    all   select  '电子商务', '100-58830', 2, 2, '5.jpg'
    union    all   select  '电子商务', '100-58830', 3, 2, '6.jpg'
    union    all   select  'E-网营销', '102-44064', 5, 1, '7.jpg'--查询示例
    declare @class int
    set @class=2select ta.*
    from qktable as ta 
    where not exists(
    select *
    from qktable
    where qk_class=@class
    and ta.qk_gjissn=qk_gjissn
    and ta.qk_djq<qk_djq)
    and qk_class=@class
      

  3.   

    Select A.* from qktable A
    Inner Join (Select qk_Name,Max(qk_djq) As qk_djq from qktable Where qk_class=2 Group By qk_Name) B
    On A.qk_Name=B.qk_Name And A.qk_djq=B.qk_djq
    请问这里面的A、B干什么用的?我才学,不怎么懂,我看过的语句中都没有这样的。能解释下吗?
      

  4.   

    Select qk_Name,qk_gjissn,Max(qk_djq) As qk_djq,qk_img 
    from qktable 
    Where qk_class=2 
    Group By qk_Name,qk_gjissn