Mysql京东的一道面试题目 比较综合
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Mysql京东的一道面试题目 比较综合
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                ?查詢sql :求取一個(gè)月之內(nèi)每天分?jǐn)?shù)和大于40的天數(shù)大于1的人
# 憑借印象記下來的 一個(gè)意思 # 計(jì)算出每人每天的分?jǐn)?shù)和 然后每人每天分?jǐn)?shù)和要求大于40 # 然后統(tǒng)計(jì)一個(gè)月之內(nèi)每人每天分?jǐn)?shù)大于40的天數(shù),要求一個(gè)月之內(nèi)每人每天分?jǐn)?shù)大于40的天數(shù)大于1 select id,count(id) num,sum(afterscore) res from ( select sum(score) as afterscore,id,time from score where time between '2019-09-01' and '2019-09-30' group by id,time having afterscore>40 ) as temptable group by temptable.id having num>1;表格與查詢結(jié)果
建表sql?
SET FOREIGN_KEY_CHECKS=0;-- ---------------------------- -- Table structure for score -- ---------------------------- DROP TABLE IF EXISTS `score`; CREATE TABLE `score` (`id` int(10) DEFAULT NULL,`score` varchar(11) DEFAULT NULL,`time` date DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;-- ---------------------------- -- Records of score -- ---------------------------- INSERT INTO `score` VALUES ('1', '255', '2019-09-04'); INSERT INTO `score` VALUES ('1', '44', '2019-09-15'); INSERT INTO `score` VALUES ('2', '67', '2019-09-13'); INSERT INTO `score` VALUES ('3', '55', '2019-09-15'); INSERT INTO `score` VALUES ('3', '12', '2019-09-19'); INSERT INTO `score` VALUES ('3', '56', '2019-09-19'); INSERT INTO `score` VALUES ('3', '44', '2019-09-19'); INSERT INTO `score` VALUES ('4', '2', '2019-09-04'); INSERT INTO `score` VALUES ('4', '333', '2019-09-12'); INSERT INTO `score` VALUES ('4', '44', '2019-09-12'); INSERT INTO `score` VALUES ('4', '55555', '2019-09-13'); INSERT INTO `score` VALUES ('4', '444', '2019-06-19');? ??
?
總結(jié)
以上是生活随笔為你收集整理的Mysql京东的一道面试题目 比较综合的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 反思应对焦虑:尽人事 听天命
 - 下一篇: 股市20日均线怎么看