当前位置:网站首页>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
边栏推荐
- Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)
- 使用oap切面导致controller被重复调用
- Remote - basic principle introduction
- Matlab---eeglab check EEG signal
- Qixin Jushi cloud spectrum new chapter | Haitai Fangyuan and Sichuan Unicom reach ecological strategic cooperation
- process.env
- I live far away. Is there a good way to open an account? Is it safe to open a stock account by mobile phone?
- 【单细胞高级绘图】07.KEGG富集结果展示
- Yolov7 training error indexerror: list index out of range
- [technical dry goods] how to ensure the idempotency of the interface?
猜你喜欢

Too many passwords, don't know how to record? Why don't you write a password box applet yourself

接口测试工具 restlet client

【网络教程】IPtables官方教程--学习笔记2

Character function and string function (2)

Force deduction ----- calculate the money of the force deduction bank

Debugged PEB (beingdebugged, ntglobalflag)

Achieve accurate positioning based on Tencent map, and realize the attendance punch function of wechat applet

Canvas 填充渐变

Remote—基本原理介绍

Remote - basic principle introduction
随机推荐
Hello, I'd like to ask questions about C and database operation.
【单细胞高级绘图】07.KEGG富集结果展示
Vulnhub | dc: 6 | [actual combat]
DDD的Go实战
How to obtain the subordinate / annotation information of KEGG channel
cts测试步骤(卡西欧cts200测试)
yuv422转rgb(422sp转420p)
Golang language quickly get started to comprehensive practical notes (go language, beego framework, high concurrency chat room, crawler)
If the order is not paid for 30 minutes, it will be automatically cancelled. How to achieve this? (Collection Edition)
Debugged PEB (beingdebugged, ntglobalflag)
基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能
ROS_ Rqt toolbox
preprocessor directives
Today's sleep quality record 75 points
Vivo official website app full model UI adaptation scheme
如何自动生成短链?如何在线批量生成带UTM参数的链接?
What's special about Huawei's innovative solutions to consolidate the foundation of ERP for small and medium-sized enterprises?
一道golang中关于map的并发读写的面试题
Leetcode-114: expand binary tree into linked list
Open source SPL enhances mangodb computing