lzh022217的gravatar头像
lzh0222172015-06-07 12:20:47

双色球手机投注:Mysql按某个字段实现分组统计Top5 Sql语法查询语句

上海快三今日开奖走势国结果 www.6r52v.cn SET @id:= 0,@type1:= '';

SELECT dsx.row_number, dsx.type, dsx.type_name, dsx.SKU, dsx.number
FROM
(
SELECT b.type, b.type_name, b.SKU, b.number,
       @id:= IF(@type1 = type,@id+1,1) as row_number, @type1:= type
FROM

   SELECT a.type, a.type_name, a.SKU, a.number
   FROM
   (
    SELECT "01" AS type,"01类别" AS type_name, "00000001" AS SKU, 213 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000002" AS SKU, 234 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000003" AS SKU, 345 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000004" AS SKU, 454 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000005" AS SKU, 223 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000006" AS SKU, 123 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000007" AS SKU, 321 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000008" AS SKU, 741 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000009" AS SKU, 463 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000010" AS SKU, 127 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000011" AS SKU, 147 AS number UNION ALL
    SELECT "01" AS type,"01类别" AS type_name, "00000012" AS SKU, 134 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000013" AS SKU, 129 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000014" AS SKU, 342 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000015" AS SKU, 232 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000016" AS SKU, 444 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000017" AS SKU, 555 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000018" AS SKU, 666 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000019" AS SKU, 332 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000020" AS SKU, 234 AS number UNION ALL
    SELECT "02" AS type,"02类别" AS type_name, "00000021" AS SKU, 532 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000022" AS SKU, 121 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000023" AS SKU, 231 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000024" AS SKU, 875 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000025" AS SKU, 587 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000026" AS SKU, 569 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000027" AS SKU, 487 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000028" AS SKU, 478 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000029" AS SKU, 587 AS number UNION ALL
    SELECT "03" AS type,"03类别" AS type_name, "00000030" AS SKU, 789 AS number 
   ) AS a
   ORDER BY a.type, a.number DESC
) AS b
) AS dsx
WHERE dsx.row_number <=5


打赏

顶部客服微信二维码底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友
  • 华媒:荷兰超市提倡减少使用一次性塑料制品 2018-07-13
  • 抓住党的建设着力点,焕发全党蓬勃活力  2018-07-12
  • 湖州市从细从实依法治路 2018-07-12
  • 【新时代 新作为 新篇章】“煤老大”渐行渐远 新动能清风徐来 2018-07-11
  • 西部网(陕西新闻网)www.cnwest.com 2018-07-11
  • 平凡人生闪耀璀璨的生命光华——“中国网事·感动2017”颁奖典礼侧记 2018-07-10
  • 为什么截留信马克的帖子?这还有摆事实讲道理存在吗? 2018-07-10
  • 甘肃省酒泉市:推行“一办四室一中心”工作模式 2018-07-09
  • 马克思主义通过指导无产阶级革命建立起部分社会财富公有制而改变了人类历史发展进程,离开部分社会财富公有制的建立来谈“改变人类历史发展进程”纯粹是无稽之谈。 2018-07-08
  • 面包屑-热门标签-华商生活 2018-07-07
  • 湖南省首届科技创新战略咨询专家委员会成立 2018-07-06
  • 【新媒体矩阵】长城新媒体微信 2018-07-05
  • 999| 685| 889| 301| 977| 390| 836| 863| 675| 450|