CREATE TABLE `tb_single_product` (
  `id` int(11) NOT NULL auto_increment,
  `sigleUserId` varchar(50) default NULL,
  `provider` varchar(50) default NULL,
  `providerCountry` varchar(50) default NULL,
  `sku` varchar(50) default NULL,
  `developer` varchar(50) default NULL,
  `title` varchar(50) default NULL,
  `version` varchar(50) default NULL,
  `productType` varchar(50) default NULL,
  `units` int(50) default NULL,
  `developerProceeds` varchar(50) default NULL,
  `beginDate` timestamp NULL default NULL,
  `endDate` timestamp NULL default NULL,
  `customerCurrency` varchar(50) default NULL,
  `countryCode` varchar(50) default NULL,
  `currencyofProceeds` varchar(50) default NULL,
  `appleIdentifier` varchar(50) default NULL,
  `customerPrice` double default NULL,
  `promoCode` varchar(50) default NULL,
  `parentIdentifier` varchar(50) default NULL,
  `subscription` varchar(50) default NULL,
  `period` varchar(50) default NULL,
  PRIMARY KEY  (`id`)
)
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('1','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','15','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('2','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','BR','USD','535358467','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('3','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','9','0','2013-09-08 00:00:00','2013-09-08 00:00:00','GBP','GB','GBP','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('4','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','IE','EUR','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('5','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','3','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','AM','USD','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('6','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','AE','USD','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('7','4','APPLE','US','com.gate9pan.dragontown.unlimitedsteps',' ','Unlimited Steps',' ','IA1','3','60','2013-09-08 00:00:00','2013-09-08 00:00:00','JPY','JP','JPY','535370295','85',' ','dragontown',NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('8','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','60','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CNY','CN','CNY','535358467','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('9','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','18','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','VN','USD','535358467','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('10','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','CO','USD','535358467','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('11','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','17','0','2013-09-08 00:00:00','2013-09-08 00:00:00','JPY','JP','JPY','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('12','4','APPLE','US','com.gate9pan.dragontown.unlimitedsteps',' ','Unlimited Steps',' ','IA1','1','.7','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','US','USD','535370295','0',' ','dragontown',NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('13','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','IT','EUR','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('14','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','ES','EUR','535372564','0',NULL,NULL,NULL,NULL);
insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('15','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','.63','2013-09-08 00:00:00','2013-09-08 00:00:00','AUD','AU','AUD','535358467','0',NULL,NULL,NULL,NULL);关键字段说明  tilte:游戏名称,units:下载量,customerPrice:收益钱数,countryCode:地区代码我要查询出  某款游戏的最高下载量及地区代码   该游戏最高收益钱数及地区代码结果类似传奇小镇       最高下载量  最高下载的地区代码   最高收益  最高收益所在的地区代码
Dragon Town™   最高下载量  最高下载的地区代码   最高收益  最高收益所在的地区代码
游戏名称   ::  ::  ::   ::  ::  ::求解啊  急死我了擦  sql太次了  得补一补了

解决方案 »

  1.   

    再发一些数据insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('16','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','8','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','ES','EUR','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('17','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','3','0','2013-09-08 00:00:00','2013-09-08 00:00:00','SEK','SE','SEK','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('18','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','27','0','2013-09-08 00:00:00','2013-09-08 00:00:00','TWD','TW','TWD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('19','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','112','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','US','USD','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('20','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','.7','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('21','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','14','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('22','4','APPLE','US','com.gate9pan.dragontown.unlimitedsteps',' ','Unlimited Steps',' ','IA1','1','.7','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535370295','0',' ','dragontown',NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('23','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','NZD','NZ','NZD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('24','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','39','8','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','IT','EUR','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('25','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','3','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','PH','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('26','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','1','5','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','LU','EUR','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('27','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CHF','CH','CHF','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('28','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','2','5','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','DE','EUR','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('29','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','PA','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('30','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','4','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','MO','USD','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('31','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','102','0','2013-09-08 00:00:00','2013-09-08 00:00:00','JPY','JP','JPY','535358467','0',NULL,NULL,NULL,NULL);
      

  2.   

    再来一些   真诚求解insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('33','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','33','0','2013-09-08 00:00:00','2013-09-08 00:00:00','EUR','FR','EUR','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('34','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','HKD','HK','HKD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('35','4','APPLE','US','com.gate9pan.dragontowncn.unlimitedsteps',' ','无限步数',' ','IA1','1','2.8','2013-09-08 00:00:00','2013-09-08 00:00:00','CAD','CA','CAD','535406416','3',' ','DragonTownCN',NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('36','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','GT','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('37','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','CL','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('38','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','CL','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('39','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','1','91','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','US','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('40','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','12','0','2013-09-08 00:00:00','2013-09-08 00:00:00','AUD','AU','AUD','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('41','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','2','0','2013-09-08 00:00:00','2013-09-08 00:00:00','NZD','NZ','NZD','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('42','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','3659','0','2013-09-08 00:00:00','2013-09-08 00:00:00','CNY','CN','CNY','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('43','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','7','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','RU','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('44','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','60','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','TH','USD','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('45','4','APPLE','US','dragontown','Gate9','Dragon Town™','1.0.1','7','3','0','2013-09-08 00:00:00','2013-09-08 00:00:00','MXN','MX','MXN','535358467','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('46','4','APPLE','US','DragonTownCN','Gate9','传奇小镇™','1.0.0','1','1','0','2013-09-08 00:00:00','2013-09-08 00:00:00','USD','VN','USD','535372564','0',NULL,NULL,NULL,NULL);
    insert into `tb_single_product` (`id`, `sigleUserId`, `provider`, `providerCountry`, `sku`, `developer`, `title`, `version`, `productType`, `units`, `developerProceeds`, `beginDate`, `endDate`, `customerCurrency`, `countryCode`, `currencyofProceeds`, `appleIdentifier`, `customerPrice`, `promoCode`, `parentIdentifier`, `subscription`, `period`) values('47','4','APPLE','US','com.gate9pan.dragontowncn.unlimitedsteps',' ','无限步数',' ','IA1','4','17.5','2013-09-08 00:00:00','2013-09-08 00:00:00','CNY','CN','CNY','535406416','25',' ','DragonTownCN',NULL,NULL);
      

  3.   

    select tilte,
    最高下载量,
    (select countryCode from tb_single_product where tilte=a.tilte and units=a.最高下载量 limit 1) as 最高下载的地区代码,
    最高收益,
    (select countryCode from tb_single_product where tilte=a.tilte and customerPrice=a.最高收益 limit 1) as 最高收益所在的地区代码
    from (
    select tilte,
    max(units) as 最高下载量,
    max(customerPrice) as 最高收益
    from tb_single_product
    group by tilte
    ) a 
      

  4.   


    好吧  我服了  你都没有建表执行就可以写出来  这就是差距啊我把title写成tilte    崇拜一下   
      

  5.   


    大神  我现在要加一个 下载量的总和  怎么加呢  我搞半天没加上下载量字段是:units  条件是 productType字段等于1或者7的 
    select sum(units),title from tb_single_product where productType='1' or  productType='7' group by title 查出来后  不知道怎么往你那里嵌套  如果游戏没有下载量就让他为null或者0都行
    再帮下吧。。   麻烦了
      

  6.   


    哦  哦 知道了  用左关联搞定了
    SELECT a.title, units,
    最高下载量,
    (SELECT countryCode FROM tb_single_product WHERE title=a.title AND units=a.最高下载量 LIMIT 1) AS 最高下载的地区代码,
    最高收益,
    (SELECT countryCode FROM tb_single_product WHERE title=a.title AND customerPrice=a.最高收益 LIMIT 1) AS 最高收益所在的地区代码
    FROM (
    SELECT title,
    MAX(units) AS 最高下载量,
    MAX(customerPrice) AS 最高收益
    FROM tb_single_product
    GROUP BY title
    ) a LEFT  JOIN
    (SELECT SUM(units) units,title FROM tb_single_product WHERE productType='1' OR  productType='7' GROUP BY title ) b
    ON a.title = b.title这代码要是在上千万的数据时候 不得查个几分钟啊。