Select DISTINCT main from kind order by id desc
提示出错

解决方案 »

  1.   

    SELECT DISTINCT Main FROM Kind ORDER BY [id] DESC
      

  2.   

    Select DISTINCT [main] from kind order by id desc
      

  3.   

    Select DISTINCT(main),id from kind order by id desc
      

  4.   

    Select DISTINCT id,main from kind order by id desc
      

  5.   

    Select DISTINCT(main)id from kind order by id desc
      

  6.   

    说明:
    我的表如下
    A  B  C
    1  a  d
    2  a  b
    3  d  a
    4  c  i
    5  c  c
    6  d  l
    要查询出来的是
    第1,3,4
    也就是说查询出B段里面不同的值Select DISTINCT [main] from kind order by id desc
    这一条不可以提示:ORDER BY 子句与 (id) DISTINCT 冲突其他的如:Select DISTINCT id,main from kind order by id desc
    查出来的是1,3,4,6 //变成不同的多了一个A字段了谢谢
      

  7.   

    为什么要用order by?
    Select DISTINCT main from kind order by main desc
    或者
    select a.main from (select distinct id,main from kind order by id desc) a
      

  8.   

    上面错了,第二句:
    select distinct a.main from (select distinct id,main from kind order by id desc) a
      

  9.   

    直接Select Min(A) As A From TableName Group By B不就OK
      

  10.   

    Create Table TEST
    (A Int,
     B Varchar(2),
     C Varchar(2))
    Insert TEST Select 1,  'a',  'd'
    Union All Select 2,  'a',  'b'
    Union All Select 3,  'd',  'a'
    Union All Select 4,  'c',  'i'
    Union All Select 5,  'c',  'c'
    Union All Select 6,  'd',  'l'
    GO
    Select Min(A) As A From TEST Group By B Order By A
    GO
    Drop Table TEST
    --Result
    /*
    A
    1
    3
    4
    */
      

  11.   

    Select DISTINCT id,main from kind where id in('1','3','4') order by id desc
      

  12.   

    select a.main from (select distinct id,main from kind order by id desc) a
    这一条语句查询出来和select distinct main from kind 一样
    并不能实现main ID小的在前面他只是按main的排列至于楼上的那个更不可能了,我上面那个表是示例表
    如果像你那样的话我直接查134不是得了
    谢谢
      

  13.   

    你能不能再說明一下,根據以下數據,你的結果是啥??我的表如下
    A  B  C
    1  a  d
    2  a  b
    3  d  a
    4  c  i
    5  c  c
    6  d  l
    如果只是取A這一行,完全就可以用Group By。另外,不要把你的問題過分簡化。不然寫出來的語句不一定適合你。