In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve mysql group by problem". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
The data tables are as follows:
Demand counts who has the highest wages in each department.
sql select NAME,desp, MAX(price) from show_plan GROUP BY desp
name , desp are the first data...
Correct statement: Use temporary tables. The first time, sort by price desc.
drop TABLE tmp3 ;
CREATE TABLE tmp3 (SELECT * from show_plan ORDER BY price DESC ) ;
SELECT * from tmp3 GROUP BY desp
It is strange that the sql result below is incorrect.
SELECT * from (SELECT * from show_plan ORDER BY price DESC) b GROUP BY b.desp
The result of the implementation of Article 1 is the same...
With the table statement, the judge can test it by himself.
DROP TABLE IF EXISTS `show_plan`;
CREATE TABLE `show_plan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` char(4) NOT NULL,
`desp` int(11) NOT NULL,
`price` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB ;
INSERT INTO `show_plan` VALUES ('1', 'a1', '1', '55');
INSERT INTO `show_plan` VALUES ('2', 'a2', '1', '20');
INSERT INTO `show_plan` VALUES ('3', 'a3', '1', '63');
INSERT INTO `show_plan` VALUES ('4', 'a4', '2', '89');
INSERT INTO `show_plan` VALUES ('5', 'a5', '2', '78');
INSERT INTO `show_plan` VALUES ('6', 'a6', '2', '90');
INSERT INTO `show_plan` VALUES ('7', 'a7', '3', '88');
INSERT INTO `show_plan` VALUES ('8', 'a8', '3', '77');
INSERT INTO `show_plan` VALUES ('9', 'a9', '3', '100');
INSERT INTO `show_plan` VALUES ('10', 'a10', '1', '77');
INSERT INTO `show_plan` VALUES ('11', 'a11', '4', '75');
"How to solve mysql group by problem" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.