select max(数量) from YourTableName where 时间='2007-07'

解决方案 »

  1.   


    SELECT TOP 1 * FROM 表 WHERE 时间属于7月份 ORDER BY 数量 DESC
      

  2.   

    select top 1 * from YourTableName where left(时间,7)='2007-07' order by 数量 desc
      

  3.   

    select max(数量) from 表明 where 时间='2007-7'
      

  4.   

    select top 1 * from Table where 时间='2007-07' order by 数量 desc
      

  5.   

    select 物品,count(*) from TB  WHRE DATEdiff(m,时间,'2007-07-01')=0 group by 物品 order by count(*) desc 
      

  6.   

    select top  1 * from TB WHRE DATEdiff(m,时间,'2007-07-01')=0 order by 数量 desc  
     
      

  7.   


    select 物品,sum(数量) as 数量 from table where 时间='2007-7' group by 物品 order  数量 desc
      

  8.   


    这位大大 正解 判断时间当然要用:DATEdiff()
      

  9.   

    select top 1 物品,count(*) from TB WHRE DATEpart(m,时间)=7 and DATEpart(yyyy ,时间)=2007 group by 物品 order by count(*) desc
      

  10.   

    SELECT TOP 1 * FROM 表 WHERE 时间属于7月份 ORDER BY 数量 DESC
      

  11.   

    如果是oracle的话top 1 和first是用不了的
      

  12.   

    select max(数量) from YourTableName where 时间='2007-07'
      

  13.   

    select * from xxx where time='xxx' order by number desc
      

  14.   

    select 物品,max(sum(数量)) as num from 表 where 时间.year = '2007' and 时间.month = '07' order by num desc limit 1
      

  15.   

    select * from(
            select t.product, sum(mount)
              from 表  t
             where to_char(时间, 'yyyymm') = to_char('2010-07-01', 'yyyymm')
             group by t.product
             order by sum(mount) desc) b
             where rownum=1
      

  16.   

    select 物品,sum(数量) as 数量 from table where 时间='2007-7' group by 物品 order 数量 desc
    再取出第一条
      

  17.   

    不够严谨,要是很多物品并列第一的话,你就不全了select * from 数据表 where datepart(year,getdate())=2010 and datepart(month,getdate())=7 and
    [数量]=(select max([数量]) from 数据表 where datepart(year,getdate())=2010 and datepart(month,getdate())=7)
      

  18.   

    select 物品 where 时间="2007-1-1" order by 数量 desc
    http://www.abab123.com/bbs/down.asp?html=1438240
    在这里找找,可能对你有帮助
      

  19.   

    select name from 
    (select top 1 name,SUM(shuliang) as ss from dbo.Table_2 where time='2007-7-7' group by name order by ss desc) as temp得到你符合你要求的名字
      

  20.   

    SELECT top 1 物品,Max(数量) FROM 表 WHERE 时间属于7月份 max(数量)desc group by 物品
      

  21.   

    SELECT top 1 物品,Max(数量) FROM 表 WHERE 时间属于7月份 order by max(数量)desc group by 物品