当前位置:网站首页>Database SQL statement exercise "suggestions collection"
Database SQL statement exercise "suggestions collection"
2022-07-25 21:00:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
1、 Count the number of vehicles under the same house :
SELECT houseid,COUNT(*) FROM t_car GROUP BY houseId;
2、 stay 1 On the basis of , Count the room number with the largest number of vehicles
SELECT houseId,COUNT(*) as car_num FROM t_car GROUP BY houseId ORDER BY car_num DESC LIMIT 1;
3、 Use one sql Batch addition of statements 3 strip t_car Record
INSERT INTO `t_car` VALUES (‘00111’, ‘ E AB1000’, ‘11111111111111111111111111111121’, ‘car_brand_01’, ‘car_color_01’, ‘car_type_01’, ‘2017-07-23 12:12:00’, ”), (‘00112’, ‘ E AC1234’, ‘11111111111111111111111111111122’, ‘car_brand_02’, ‘car_color_02’, ‘car_type_02’, ‘2018-07-12 12:12:00’, NULL), (‘00113’, ‘ E AD9999’, ‘11111111111111111111111111111123’, ‘car_brand_03’, ‘car_color_00’, ‘car_type_00’, ‘2018-07-12 12:12:00’, NULL);
4、 Delete payment on 2017 year 1 month 1 Payment records before day
DELETE FROM t_car_pay WHERE DATE(payTime)<‘2018-01-01’;
5、 Delete payment on 2017 year 1 month 1 Vehicle records before day
DELETE FROM t_car where carId in(SELECT carId from t_car_pay where DATE(payTime)<‘2018-01-01’);
DELETE c.*,p.* FROM t_car c , t_car_pay p WHERE (c.carid=p.carid ) AND DATE(p.payTime)<‘2018-01-01’; Delete multiple tables at the same time
6、 Use one according to the license plate number sql Statement batch modify the picture information of the vehicle
UPDATE t_car_image set path= ‘A-00benz.jpg’ WHERE carid in (select carid from t_car where carNumber=’ E AL0000′ )
7、 Check the latest payment records of all vehicles
select * from t_car_pay p where 1>(select COUNT(*) from t_car_pay where carId=p.carid and payTime>p.payTime) ORDER BY p.carId,p.payTime desc;
Reference resources :
Before grouping N Record
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127838.html Link to the original text :https://javaforall.cn
边栏推荐
- leetcode-6127:优质数对的数目
- Pycharm跑程序时自动进入测试模式
- 7.23
- In June 2021, the interview suffered a Waterloo. Is it so convoluted now
- An interview question about recover in golang
- How to obtain the subordinate / annotation information of KEGG channel
- Interpretation of filter execution sequence source code in sprigboot
- seven point two three
- As a test, how to understand thread synchronization and asynchrony
- [technical dry goods] how to ensure the idempotency of the interface?
猜你喜欢
What's special about Huawei's innovative solutions to consolidate the foundation of ERP for small and medium-sized enterprises?

Unity vs -- the default debugging in VS is to start rather than attach to unity debugging

Add startup software items when the win system starts up

Cesium 多边形渐变色纹理(Canvas)

LeetCode刷题——猜数字大小II#375#Medium
![[MCU] 51 MCU burning those things](/img/fa/8f11ef64a18114365c084fff7d39f6.png)
[MCU] 51 MCU burning those things

Success factors of software R & D effectiveness measurement

Remote - basic principle introduction

Opencv learning Fourier transform experience and line direction Fourier transform code
![[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes](/img/65/4dd3a521946e753c79d3db1fa0a4f4.png)
[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
随机推荐
Step num problem
Question and answer 47: geeks have an appointment - the current monitoring system construction of CSC
Vivo official website app full model UI adaptation scheme
Canvas fill gradient
cuda_error_out_of_memory(out of memory怎么办)
[MSA] a brief description of the moveit Configuration Assistant chain in planning groups
Leetcode-919: complete binary tree inserter
Sum of two numbers and three numbers
zigbee物联网开发平台(工业物联网)
As a test, how to understand thread synchronization and asynchrony
Interpretation of filter execution sequence source code in sprigboot
Detailed explanation of document operation
【网络教程】IPtables官方教程--学习笔记2
Implementation of simple registration and login
牛客-TOP101-BM38
Card link
Pychart automatically enters the test mode when running the program
[online tutorial] iptables official tutorial -- learning notes 2
Remote - actual combat
Unity VS—— VS中默认调试为启动而不是附加到Unity调试