李家的张麻子:ETL工程师的数据库编程之旅,用ChatGPT打破常规!

李家的张麻子:ETL工程师的数据库编程之旅,用ChatGPT打破常规!_第1张图片

数据库编程大赛:一条SQL计算扑克牌24点

12月27日,NineData和云数据库技术社区主办,华为云、火山引擎、开源中国、云和恩墨、TDengine、云猿生数据、DORIS、ITPUB等协办单位和媒体,共同举办了本次《数据库编程大赛》。大赛题目「用一条SQL给出扑克牌24点的计算表达式」。

以下冠军选手李家的张麻子的参赛情况的介绍:

李家的张麻子:ETL工程师的数据库编程之旅,用ChatGPT打破常规!_第2张图片

参赛选手:李家的张麻子

个人简介:ETL工程师

参赛数据库:SQL Server

性能评测:百万级数据代码性能评测 5.52秒

综合得分:72.6

以下是李家的张麻子选手的代码说明思路:

选手采用的是“人工”穷举算法。值得一提的是,该选手是少数成功使用ChatGPT生成SQL的。首先通过详细列举和排序的方式,全面呈现了所有可能性,并在此基础上由ChatGPT生成SQL代码,再进行适当调整。尽管这种方法稍显粗暴,但是打破常规,正确的运用AI,也是一种新颖的方式。

以下是李家的张麻子选手的算法说明,结尾附完整SQL:


算法说明:

24点SQL编程大赛算法说明(暴力枚举)(SQL SERVER)

1.24点的有效数字组合是有限的,那么我们使用工具(chatgpt等),枚举所有的组合(减去一些重复组合)和一个解法,组成一个结果集。比如(1,1,8,1),(8,1,1,1),(1,8,1,1)(1,1,1,8),只需提取(1,1,1,8)这个组成一个字符数字’1118’,并附带一个解法,最后出的结果就是如下:

With t as (
Select '1118','8×(1+1+1)'
Union all
Select '1126','2×6×(1+1)'
Union all
...
)

2.测试数据集中的数据,我们同样可以用以上的方法,使用工具或者人工将每一行数据使用case when 方法全部罗列排序拼接,因为只有4个数字,那么就是24种情况,如下:

With tt as (
Select 
CASE WHEN c1>=c2 AND c2>=c3 AND c3>=c4 THEN CONCAT(c4,c3,c2,c1) 
CASE WHEN ...
END gs
)

3.根据步骤二排序拼接得到的gs字段就是从小到大的排列后的数字,跟步骤以的结果集去匹配即可。

参赛完整SQL:

WITH t AS (SELECT k.s,k.ss FROM (SELECT '1118' s,'8×(1+1+1)' ss UNION ALL SELECT '1126','2×6×(1+1)' UNION ALL SELECT'1127','(1+2)×(7+1)' UNION ALL SELECT'1128','(1+2)×8×1'UNION ALL SELECT'1129','(1+2)×(9-1)'UNION ALL SELECT'11210','2×(1+10+1)'UNION ALL SELECT'1134','3×4×(1+1)'UNION ALL SELECT'1135','(1+3)×(5+1)'UNION ALL SELECT'1136','(1+3)×6×1'UNION ALL SELECT'1137','(1+3)×(7-1)'UNION ALL SELECT'1138','1+3×8-1'UNION ALL SELECT'1139','1×3×(9-1)'UNION ALL SELECT'11310','3×(10-1-1)'UNION ALL SELECT'1144','4×(1+4+1)'UNION ALL SELECT'1145','(1+4)×5-1'UNION ALL SELECT'1146','1+4×6-1'UNION ALL SELECT'1147','1×4×(7-1)'UNION ALL SELECT'1148','(4-1)×8×1'UNION ALL SELECT'1149','(4-1)×(9-1)'UNION ALL SELECT'11410','4+10×(1+1)'UNION ALL SELECT'1155','(1+5)×(5-1)'UNION ALL SELECT'1156','(5-1)×6×1'UNION ALL SELECT'1157','(5-1)×(7-1)'UNION ALL SELECT'1158','8×(5-1-1)'UNION ALL SELECT'1166','(6+6)×(1+1)'UNION ALL SELECT'1168','6×8÷(1+1)'UNION ALL SELECT'1169','6+9×(1+1)'UNION ALL SELECT'11710','10+7×(1+1)'UNION ALL SELECT'1188','8+8×(1+1)'UNION ALL SELECT'1224','2×4×(2+1)'UNION ALL SELECT'1225','(2+2)×(5+1)'UNION ALL SELECT'1226','(2+2)×6×1'UNION ALL SELECT'1227','(2+2)×(7-1)'UNION ALL SELECT'1228','8×(2+2-1)'UNION ALL SELECT'1229','2×(2+9+1)'UNION ALL SELECT'12210','2+2×(10+1)'UNION ALL SELECT'1233','2×3×(3+1)'UNION ALL SELECT'1234','2×3×4×1'UNION ALL SELECT'1235','(2+3)×5-1'UNION ALL SELECT'1236','3×(2+6)×1'UNION ALL SELECT'1237','2+3×7+1'UNION ALL SELECT'1238','2×(3+8+1)'UNION ALL SELECT'1239','2×(3+9)×1'UNION ALL SELECT'12310','2×(3+10-1)'UNION ALL SELECT'1244','(2+4)×4×1'UNION ALL SELECT'1245','(2+4)×(5-1)'UNION ALL SELECT'1246','4×6×(2-1)'UNION ALL SELECT'1247','2×(4+7+1)'UNION ALL SELECT'1248','2×(4+8)×1'UNION ALL SELECT'1249','2×(4+9-1)'UNION ALL SELECT'12410','4+2×10×1'UNION ALL SELECT'1255','5×5-2+1'UNION ALL SELECT'1256','2×(5+6+1)'UNION ALL SELECT'1257','2×(5+7)×1'UNION ALL SELECT'1258','2×(5+8-1)'UNION ALL SELECT'1259','5+2×9+1'UNION ALL SELECT'12510','5+2×10-1'UNION ALL SELECT'1266','2×(6+6)×1'UNION ALL SELECT'1267','2×(6+7-1)'UNION ALL SELECT'1268','6+2×(8+1)'UNION ALL SELECT'1269','6+2×9×1'UNION ALL SELECT'12610','6+2×(10-1)'UNION ALL SELECT'1277','(7×7-1)÷2'UNION ALL SELECT'1278','7+2×8+1'UNION ALL SELECT'1279','2×7+9+1'UNION ALL SELECT'12710','2×7+10×1'UNION ALL SELECT'1288','2×8+8×1'UNION ALL SELECT'1289','2×8+9-1'UNION ALL SELECT'12810','10+2×(8-1)'UNION ALL SELECT'1333','(3+3)×(3+1)'UNION ALL SELECT'1334','(3+3)×4×1'UNION ALL SELECT'1335','(3+3)×(5-1)'UNION ALL SELECT'1336','3+3×(6+1)'UNION ALL SELECT'1337','3+3×7×1'UNION ALL SELECT'1338','3+3×(8-1)'UNION ALL SELECT'1339','(3+9)×(3-1)'UNION ALL SELECT'13310','3×(10-3+1)'UNION ALL SELECT'1344','3×(4+4)×1'UNION ALL SELECT'1345','3+4×5+1'UNION ALL SELECT'1346','6÷(1-3÷4)'UNION ALL SELECT'1347','4+3×7-1'UNION ALL SELECT'1348','(4+8)×(3-1)'UNION ALL SELECT'1349','4×(9-3)×1'UNION ALL SELECT'13410','4+10×(3-1)'UNION ALL SELECT'1356','5+3×6+1'UNION ALL SELECT'1357','(5+7)×(3-1)'UNION ALL SELECT'1358','3×5+8+1'UNION ALL SELECT'1359','3×5+9×1'UNION ALL SELECT'13510','3×5+10-1'UNION ALL SELECT'1366','3×6+6×1'UNION ALL SELECT'1367','3×6+7-1'UNION ALL SELECT'1368','(6-3)×8×1'UNION ALL SELECT'1369','(6-3)×(9-1)'UNION ALL SELECT'13610','3×10-6×1'UNION ALL SELECT'1377','(7-3)×(7-1)'UNION ALL SELECT'1378','8×(7-3-1)'UNION ALL SELECT'1379','9÷3×(7+1)'UNION ALL SELECT'13710','10+7×(3-1)'UNION ALL SELECT'1388','8÷3×(8+1)'UNION ALL SELECT'1389','8÷3×9×1'UNION ALL SELECT'13810','8÷3×(10-1)'UNION ALL SELECT'1399','9÷3×(9-1)'UNION ALL SELECT'13910','3×(10+1)-9'UNION ALL SELECT'131010','3+10+10+1'UNION ALL SELECT'1444','4+4×(4+1)'UNION ALL SELECT'1445','4+4×5×1'UNION ALL SELECT'1446','4+4×(6-1)'UNION ALL SELECT'1447','4×4+7+1'UNION ALL SELECT'1448','4×4+8×1'UNION ALL SELECT'1449','4×4+9-1'UNION ALL SELECT'14410','4×(10-4)×1'UNION ALL SELECT'1455','4+5×(5-1)'UNION ALL SELECT'1456','6÷(5÷4-1)'UNION ALL SELECT'1457','4×7-5+1'UNION ALL SELECT'1458','8+4×(5-1)'UNION ALL SELECT'1459','5×(9-4)-1'UNION ALL SELECT'14510','4×(10-5+1)'UNION ALL SELECT'1466','6+6×(4-1)'UNION ALL SELECT'1467','6×(7-4+1)'UNION ALL SELECT'1468','6×(8-4)×1'UNION ALL SELECT'1469','6×(9-4-1)'UNION ALL SELECT'14610','10×(4-1)-6'UNION ALL SELECT'1477','(7-4)×(7+1)'UNION ALL SELECT'1478','(7-4)×8×1'UNION ALL SELECT'1479','(7-4)×(9-1)'UNION ALL SELECT'1488','4×8-8×1'UNION ALL SELECT'1489','4×8-9+1'UNION ALL SELECT'14910','4+9+10+1'UNION ALL SELECT'141010','4+10+10×1'UNION ALL SELECT'1555','5×(5-1÷5)'UNION ALL SELECT'1556','5×6-5-1'UNION ALL SELECT'1559','(9-5)×(5+1)'UNION ALL SELECT'15510','5×(10-5)-1'UNION ALL SELECT'1566','5×6-6×1'UNION ALL SELECT'1567','5×6-7+1'UNION ALL SELECT'1568','6×(8-5+1)'UNION ALL SELECT'1569','6×(9-5)×1'UNION ALL SELECT'15610','6×(10-5-1)'UNION ALL SELECT'1578','8×(7-5+1)'UNION ALL SELECT'1579','(9-5)×(7-1)'UNION ALL SELECT'15710','5×7-10-1'UNION ALL SELECT'1588','(8-5)×8×1'UNION ALL SELECT'1589','(8-5)×(9-1)'UNION ALL SELECT'15810','5+8+10+1'UNION ALL SELECT'1599','5+9+9+1'UNION ALL SELECT'15910','5+9+10×1'UNION ALL SELECT'151010','5+10+10-1'UNION ALL SELECT'1666','6×(6-1)-6'UNION ALL SELECT'1668','6÷(1-6÷8)'UNION ALL SELECT'1669','6×(9-6+1)'UNION ALL SELECT'16610','6×(10-6)×1'UNION ALL SELECT'1679','(9-6)×(7+1)'UNION ALL SELECT'16710','6+7+10+1'UNION ALL SELECT'1688','8×(8-6+1)'UNION ALL SELECT'1689','6+8+9+1'UNION ALL SELECT'16810','6+8+10×1'UNION ALL SELECT'1699','6+9+9×1'UNION ALL SELECT'16910','6+9+10-1'UNION ALL SELECT'1779','7+7+9+1'UNION ALL SELECT'17710','7+7+10×1'UNION ALL SELECT'1788','7+8+8+1'UNION ALL SELECT'1789','7+8+9×1'UNION ALL SELECT'17810','7+8+10-1'UNION ALL SELECT'1799','7+9+9-1'UNION ALL SELECT'17910','(10-7)×(9-1)'UNION ALL SELECT'1888','8+8+8×1'UNION ALL SELECT'1889','8+8+9-1'UNION ALL SELECT'18810','8×(10-8+1)'UNION ALL SELECT'2223','(2+2)×3×2'UNION ALL SELECT'2224','(2+2)×(4+2)'UNION ALL SELECT'2225','(2+2×5)×2'UNION ALL SELECT'2227','2×(2×7-2)'UNION ALL SELECT'2228','(2+2+8)×2'UNION ALL SELECT'2229','2+(2+9)×2'UNION ALL SELECT'22210','2+2+10×2'UNION ALL SELECT'2233','2×(3+3)×2'UNION ALL SELECT'2234','3×(2+4+2)'UNION ALL SELECT'2235','3×(2×5-2)'UNION ALL SELECT'2236','(2×3+6)×2'UNION ALL SELECT'2237','(2+3+7)×2'UNION ALL SELECT'2238','2+(3+8)×2'UNION ALL SELECT'2239','2×3+9×2'UNION ALL SELECT'22310','2×(3+10)-2'UNION ALL SELECT'2244','(2×4+4)×2'UNION ALL SELECT'2245','2+4×5+2'UNION ALL SELECT'2246','(2+4+6)×2'UNION ALL SELECT'2247','2+(4+7)×2'UNION ALL SELECT'2248','(2+4)×8÷2'UNION ALL SELECT'2249','2+4+9×2'UNION ALL SELECT'22410','2×(4+10-2)'UNION ALL SELECT'2255','(2+5+5)×2'UNION ALL SELECT'2256','2+(5+6)×2'UNION ALL SELECT'2257','2×5+7×2'UNION ALL SELECT'2258','2×(5+8)-2'UNION ALL SELECT'2259','2×(5+9-2)'UNION ALL SELECT'22510','(5-2)×(10-2)'UNION ALL SELECT'2266','(2+6)×6÷2'UNION ALL SELECT'2267','2×(6+7)-2'UNION ALL SELECT'2268','2+6+8×2'UNION ALL SELECT'2269','(6÷2+9)×2'UNION ALL SELECT'22610','2×6+10+2'UNION ALL SELECT'2277','2×(7+7-2)'UNION ALL SELECT'2278','2×7+8+2'UNION ALL SELECT'22710','2×(7+10÷2)'UNION ALL SELECT'2288','2×(8+8÷2)'UNION ALL SELECT'2289','8+2×9-2'UNION ALL SELECT'22810','2×8+10-2'UNION ALL SELECT'22910','10+(9-2)×2'UNION ALL SELECT'221010','2+10+10+2'UNION ALL SELECT'2333','(3+3×3)×2'UNION ALL SELECT'2335','3+3×(5+2)'UNION ALL SELECT'2336','(3+3+6)×2'UNION ALL SELECT'2337','3×(3+7-2)'UNION ALL SELECT'2338','(3+3)×8÷2'UNION ALL SELECT'2339','3+3+9×2'UNION ALL SELECT'23310','3×(3+10÷2)'UNION ALL SELECT'2344','3×4×(4-2)'UNION ALL SELECT'2345','(3+4+5)×2'UNION ALL SELECT'2346','3×(4+6-2)'UNION ALL SELECT'2347','4+(3+7)×2'UNION ALL SELECT'2348','3×(4+8÷2)'UNION ALL SELECT'2349','4×(3+9)÷2'UNION ALL SELECT'23410','3×4+10+2'UNION ALL SELECT'2355','(3+5)×(5-2)'UNION ALL SELECT'2356','(3+5)×6÷2'UNION ALL SELECT'2357','3×5+7+2'UNION ALL SELECT'2358','3+5+8×2'UNION ALL SELECT'2359','(3+5×9)÷2'UNION ALL SELECT'23510','(5-3+10)×2'UNION ALL SELECT'2366','(3×6-6)×2'UNION ALL SELECT'2367','3+6×7÷2'UNION ALL SELECT'2368','3×6+8-2'UNION ALL SELECT'2369','(6-3+9)×2'UNION ALL SELECT'23610','3×(6+10)÷2'UNION ALL SELECT'2377','3+7+7×2'UNION ALL SELECT'2378','(7-3+8)×2'UNION ALL SELECT'2379','3×(7+9)÷2'UNION ALL SELECT'23710','7-3+10×2'UNION ALL SELECT'2388','3×(8+8)÷2'UNION ALL SELECT'2389','8×(9-3×2)'UNION ALL SELECT'23810','8+10+3×2'UNION ALL SELECT'2399','9-3+9×2'UNION ALL SELECT'23910','3+9+10+2'UNION ALL SELECT'231010','10-(3-10)×2'UNION ALL SELECT'2444','(4+4+4)×2'UNION ALL SELECT'2445','(4+4)×(5-2)'UNION ALL SELECT'2446','4+(4+6)×2'UNION ALL SELECT'2447','4+4×(7-2)'UNION ALL SELECT'2448','4+4+8×2'UNION ALL SELECT'2449','4×(9-2)-4'UNION ALL SELECT'24410','4+4×10÷2'UNION ALL SELECT'2455','4+(5+5)×2'UNION ALL SELECT'2456','4+5×(6-2)'UNION ALL SELECT'2457','4×(5+7)÷2'UNION ALL SELECT'2458','4+5×8÷2'UNION ALL SELECT'2459','(9-5)×(4+2)'UNION ALL SELECT'24510','4+10+5×2'UNION ALL SELECT'2466','4×(6+6)÷2'UNION ALL SELECT'2467','4+6+7×2'UNION ALL SELECT'2468','6÷4×8×2'UNION ALL SELECT'2469','6+4×9÷2'UNION ALL SELECT'24610','(6-4+10)×2'UNION ALL SELECT'2477','(7+7)×2-4'UNION ALL SELECT'2478','4×7-8÷2'UNION ALL SELECT'2479','(7-4+9)×2'UNION ALL SELECT'24710','(7-4)×(10-2)'UNION ALL SELECT'2488','8+4×8÷2'UNION ALL SELECT'2489','8×(9-4-2)'UNION ALL SELECT'24810','4+8+10+2'UNION ALL SELECT'2499','4+9+9+2'UNION ALL SELECT'24910','4×9-10-2'UNION ALL SELECT'241010','10×(4÷10+2)'UNION ALL SELECT'2557','5+5+7×2'UNION ALL SELECT'2558','8×(5÷5+2)'UNION ALL SELECT'2559','5+9+5×2'UNION ALL SELECT'25510','(5-2÷10)×5'UNION ALL SELECT'2566','6+6×(5-2)'UNION ALL SELECT'2567','6×(7-5+2)'UNION ALL SELECT'2568','5×6-8+2'UNION ALL SELECT'2569','9+6×5÷2'UNION ALL SELECT'25610','6÷5×10×2'UNION ALL SELECT'2577','7+7+5×2'UNION ALL SELECT'2578','8×(5×2-7)'UNION ALL SELECT'2579','5×7-9-2'UNION ALL SELECT'25710','5+7+10+2'UNION ALL SELECT'2588','(5×8+8)÷2'UNION ALL SELECT'2589','5+8+9+2'UNION ALL SELECT'25810','(8-5)×(10-2)'UNION ALL SELECT'25910','9-5+10×2'UNION ALL SELECT'251010','(10÷5+10)×2'UNION ALL SELECT'2666','6+6+6×2'UNION ALL SELECT'2667','(6+6×7)÷2'UNION ALL SELECT'2668','6×(8-6+2)'UNION ALL SELECT'2669','(6×9-6)÷2'UNION ALL SELECT'26610','6+6+10+2'UNION ALL SELECT'2678','8×(7-6+2)'UNION ALL SELECT'2679','6+7+9+2'UNION ALL SELECT'26710','(10-7)×(6+2)'UNION ALL SELECT'2688','6+8+8+2'UNION ALL SELECT'2689','8÷6×9×2'UNION ALL SELECT'26810','(8-6+10)×2'UNION ALL SELECT'2699','(9-6+9)×2'UNION ALL SELECT'26910','6×(9-10÷2)'UNION ALL SELECT'261010','6+10+10-2'UNION ALL SELECT'2778','7+7+8+2'UNION ALL SELECT'27710','7×(10÷7+2)'UNION ALL SELECT'2788','(7×8-8)÷2'UNION ALL SELECT'2789','(7+9)×2-8'UNION ALL SELECT'27910','7+9+10-2'UNION ALL SELECT'271010','(10-7)×(10-2)'UNION ALL SELECT'2888','8×(8÷8+2)'UNION ALL SELECT'2889','8×(9-8+2)'UNION ALL SELECT'28810','8+8+10-2'UNION ALL SELECT'2899','8+9+9-2'UNION ALL SELECT'28910','8×(10-9+2)'UNION ALL SELECT'281010','8×(10÷10+2)'UNION ALL SELECT'291010','9+10+10÷2'UNION ALL SELECT'3333','3×3×3-3'UNION ALL SELECT'3334','3+(3+4)×3'UNION ALL SELECT'3335','3×3+5×3'UNION ALL SELECT'3336','3+3+6×3'UNION ALL SELECT'3337','(3+3)×(7-3)'UNION ALL SELECT'3338','3+3×8-3'UNION ALL SELECT'3339','3×(9-3÷3)'UNION ALL SELECT'33310','3+3×(10-3)'UNION ALL SELECT'3344','3×4+4×3'UNION ALL SELECT'3345','3×(4+5)-3'UNION ALL SELECT'3346','3+4×6-3'UNION ALL SELECT'3347','3×(4+7-3)'UNION ALL SELECT'3348','(4-3)×8×3'UNION ALL SELECT'3349','(3-4+9)×3'UNION ALL SELECT'3355','5×5-3÷3'UNION ALL SELECT'3356','(3+5)×(6-3)'UNION ALL SELECT'3357','(3×5-7)×3'UNION ALL SELECT'3359','(3+5)×9÷3'UNION ALL SELECT'33510','(3-5+10)×3'UNION ALL SELECT'3366','3×(6+6÷3)'UNION ALL SELECT'3367','6+3×7-3'UNION ALL SELECT'3368','(3+6)×8÷3'UNION ALL SELECT'3369','3-6+9×3'UNION ALL SELECT'33610','(3×6-10)×3'UNION ALL SELECT'3377','7×(3÷7+3)'UNION ALL SELECT'3378','7+8+3×3'UNION ALL SELECT'3379','3+7×9÷3'UNION ALL SELECT'3388','8÷(3-8÷3)'UNION ALL SELECT'3389','8×(9-3-3)'UNION ALL SELECT'33810','3+8+10+3'UNION ALL SELECT'3399','3+9+9+3'UNION ALL SELECT'33910','3-9+10×3'UNION ALL SELECT'3444','4×(4+3)-4'UNION ALL SELECT'3445','4×4+5+3'UNION ALL SELECT'3446','(4+4)×(6-3)'UNION ALL SELECT'3447','(4÷4+7)×3'UNION ALL SELECT'3448','4+4×(8-3)'UNION ALL SELECT'3449','(4+4)×9÷3'UNION ALL SELECT'34410','4×(10-3)-4'UNION ALL SELECT'3455','4+5+5×3'UNION ALL SELECT'3456','6×(5-4+3)'UNION ALL SELECT'3457','4+5×(7-3)'UNION ALL SELECT'3458','(4+5)×8÷3'UNION ALL SELECT'3459','(4-5+9)×3'UNION ALL SELECT'34510','4÷5×10×3'UNION ALL SELECT'3466','(6-4+6)×3'UNION ALL SELECT'3468','6×(4+8)÷3'UNION ALL SELECT'3469','(6-4)×(9+3)'UNION ALL SELECT'34610','4+6×10÷3'UNION ALL SELECT'3477','4×7-7+3'UNION ALL SELECT'3478','8+4×(7-3)'UNION ALL SELECT'3479','4-7+9×3'UNION ALL SELECT'34710','4+7+10+3'UNION ALL SELECT'3489','4+8+9+3'UNION ALL SELECT'34810','4×(8+10)÷3'UNION ALL SELECT'3499','4×(9+9)÷3'UNION ALL SELECT'341010','4-10+10×3'UNION ALL SELECT'3556','6×(5÷5+3)'UNION ALL SELECT'3557','(5÷5+7)×3'UNION ALL SELECT'3558','5-5+8×3'UNION ALL SELECT'3559','5×(9÷5+3)'UNION ALL SELECT'3566','(6+6)×(5-3)'UNION ALL SELECT'3567','(6-5+7)×3'UNION ALL SELECT'3568','(6-5)×8×3'UNION ALL SELECT'3569','(5-6+9)×3'UNION ALL SELECT'35610','5+6+10+3'UNION ALL SELECT'3578','5×7-8-3'UNION ALL SELECT'3579','5+7+9+3'UNION ALL SELECT'35710','(5-7+10)×3'UNION ALL SELECT'3588','5+8+8+3'UNION ALL SELECT'3589','5-8+9×3'UNION ALL SELECT'3599','9+5×9÷3'UNION ALL SELECT'35910','9-(5-10)×3'UNION ALL SELECT'351010','(10-10÷5)×3'UNION ALL SELECT'3666','6+6×(6-3)'UNION ALL SELECT'3667','(6÷6+7)×3'UNION ALL SELECT'3668','6-6+8×3'UNION ALL SELECT'3669','6+6+9+3'UNION ALL SELECT'36610','10×(6-3)-6'UNION ALL SELECT'3677','6×(7÷7+3)'UNION ALL SELECT'3678','6+7+8+3'UNION ALL SELECT'3679','(6-7+9)×3'UNION ALL SELECT'36710','10+7×6÷3'UNION ALL SELECT'3688','6×8-8×3'UNION ALL SELECT'3689','(8-6)×(9+3)'UNION ALL SELECT'36810','(6-8+10)×3'UNION ALL SELECT'3699','6-9+9×3'UNION ALL SELECT'36910','6×9-10×3'UNION ALL SELECT'361010','6×(10÷10+3)'UNION ALL SELECT'3777','7+7+7+3'UNION ALL SELECT'3778','7-7+8×3'UNION ALL SELECT'3779','(9-7÷7)×3'UNION ALL SELECT'37710','7×(10-7)+3'UNION ALL SELECT'3788','(7+8÷8)×3'UNION ALL SELECT'3789','(7-8+9)×3'UNION ALL SELECT'3799','(7+9÷9)×3'UNION ALL SELECT'37910','(7-9+10)×3'UNION ALL SELECT'371010','7+10+10-3'UNION ALL SELECT'3888','(8+8-8)×3'UNION ALL SELECT'3889','8×(9-8)×3'UNION ALL SELECT'38810','(8×10-8)÷3'UNION ALL SELECT'3899','(8+9-9)×3'UNION ALL SELECT'38910','8+9+10-3'UNION ALL SELECT'381010','(8+10-10)×3'UNION ALL SELECT'3999','9+9+9-3'UNION ALL SELECT'39910','(9+9-10)×3'UNION ALL SELECT'391010','(9-10÷10)×3'UNION ALL SELECT'4444','4+4+4×4'UNION ALL SELECT'4445','(4÷4+5)×4'UNION ALL SELECT'4446','4+4×6-4'UNION ALL SELECT'4447','(4+4)×(7-4)'UNION ALL SELECT'4448','4×(4+8÷4)'UNION ALL SELECT'4449','4+4×(9-4)'UNION ALL SELECT'44410','(4×4-10)×4'UNION ALL SELECT'4455','4×(5+5-4)'UNION ALL SELECT'4456','(5-4)×6×4'UNION ALL SELECT'4457','(4-5+7)×4'UNION ALL SELECT'4458','4+5×(8-4)'UNION ALL SELECT'44510','4-(5-10)×4'UNION ALL SELECT'4468','(4-6+8)×4'UNION ALL SELECT'4469','4÷6×9×4'UNION ALL SELECT'44610','4+6+10+4'UNION ALL SELECT'4477','7×(4-4÷7)'UNION ALL SELECT'4478','4×7-8+4'UNION ALL SELECT'4479','4+7+9+4'UNION ALL SELECT'44710','(10-7)×(4+4)'UNION ALL SELECT'4488','4+8+8+4'UNION ALL SELECT'4489','4×9-8-4'UNION ALL SELECT'44810','4+8×10÷4'UNION ALL SELECT'441010','(10×10-4)÷4'UNION ALL SELECT'4555','(5+5÷5)×4'UNION ALL SELECT'4556','5-5+6×4'UNION ALL SELECT'4557','(7-5÷5)×4'UNION ALL SELECT'4558','8×(4-5÷5)'UNION ALL SELECT'4559','5×(9-5)+4'UNION ALL SELECT'45510','5+5+10+4'UNION ALL SELECT'4566','(5+6÷6)×4'UNION ALL SELECT'4567','(5-6+7)×4'UNION ALL SELECT'4568','8×(5-6+4)'UNION ALL SELECT'4569','5+6+9+4'UNION ALL SELECT'45610','5×6-10+4'UNION ALL SELECT'4577','(5+7÷7)×4'UNION ALL SELECT'4578','5+7+8+4'UNION ALL SELECT'4579','7×(9-5)-4'UNION ALL SELECT'45710','(7-5)×10+4'UNION ALL SELECT'4588','(5+8÷8)×4'UNION ALL SELECT'4589','(5-8+9)×4'UNION ALL SELECT'45810','5×(8÷10+4)'UNION ALL SELECT'4599','(5+9÷9)×4'UNION ALL SELECT'45910','(5-9+10)×4'UNION ALL SELECT'451010','(5+10÷10)×4'UNION ALL SELECT'4666','(6+6-6)×4'UNION ALL SELECT'4667','6+6×(7-4)'UNION ALL SELECT'4668','6+6+8+4'UNION ALL SELECT'4669','6+9×(6-4)'UNION ALL SELECT'46610','6×(6+10)÷4'UNION ALL SELECT'4677','6+7+7+4'UNION ALL SELECT'4678','(8-7)×6×4'UNION ALL SELECT'4679','6×(7+9)÷4'UNION ALL SELECT'46710','7×(10-6)-4'UNION ALL SELECT'4688','(6+8-8)×4'UNION ALL SELECT'4689','6+8×9÷4'UNION ALL SELECT'46810','8-(6-10)×4'UNION ALL SELECT'4699','(6+9-9)×4'UNION ALL SELECT'46910','(6+9×10)÷4'UNION ALL SELECT'461010','(6+10-10)×4'UNION ALL SELECT'4777','(7-7÷7)×4'UNION ALL SELECT'4778','(7+7-8)×4'UNION ALL SELECT'4788','(7-8÷8)×4'UNION ALL SELECT'4789','(7+8-9)×4'UNION ALL SELECT'47810','10+8×7÷4'UNION ALL SELECT'4799','(7-9÷9)×4'UNION ALL SELECT'47910','(7+9-10)×4'UNION ALL SELECT'471010','(7-10÷10)×4'UNION ALL SELECT'4888','8+8×8÷4'UNION ALL SELECT'4889','8×(8-9+4)'UNION ALL SELECT'48810','(8+8-10)×4'UNION ALL SELECT'4899','(4-9÷9)×8'UNION ALL SELECT'48910','8×(9-10+4)'UNION ALL SELECT'481010','8+10+10-4'UNION ALL SELECT'49910','9+9+10-4'UNION ALL SELECT'5555','5×5-5÷5'UNION ALL SELECT'5556','5×5-6+5'UNION ALL SELECT'5559','5+5+9+5'UNION ALL SELECT'5566','5×(6-6÷5)'UNION ALL SELECT'5567','6-7+5×5'UNION ALL SELECT'5568','5+6+8+5'UNION ALL SELECT'5577','5+7+7+5'UNION ALL SELECT'5578','7-8+5×5'UNION ALL SELECT'55710','(5+7)×10÷5'UNION ALL SELECT'5588','5×5-8÷8'UNION ALL SELECT'5589','8-9+5×5'UNION ALL SELECT'55810','8×(5+10)÷5'UNION ALL SELECT'5599','5×5-9÷9'UNION ALL SELECT'55910','9-10+5×5'UNION ALL SELECT'551010','5×5-10÷10'UNION ALL SELECT'5666','6×(5-6÷6)'UNION ALL SELECT'5667','6+6+7+5'UNION ALL SELECT'5668','6+6×(8-5)'UNION ALL SELECT'5669','6×9-6×5'UNION ALL SELECT'56610','(6+6)×10÷5'UNION ALL SELECT'5677','(5-7÷7)×6'UNION ALL SELECT'5678','6×(7-8+5)'UNION ALL SELECT'5679','6+9×(7-5)'UNION ALL SELECT'5688','8×(6-8+5)'UNION ALL SELECT'5689','6×(8-9+5)'UNION ALL SELECT'56810','6×8÷10×5'UNION ALL SELECT'5699','9-(6-9)×5'UNION ALL SELECT'56910','6+9×10÷5'UNION ALL SELECT'561010','6×(10+10)÷5'UNION ALL SELECT'5779','(9-7)×(7+5)'UNION ALL SELECT'57710','10+7×(7-5)'UNION ALL SELECT'5788','(7+8)×8÷5'UNION ALL SELECT'5789','8×(7-9+5)'UNION ALL SELECT'57810','(10-8)×(7+5)'UNION ALL SELECT'57910','9-(7-10)×5'UNION ALL SELECT'571010','10+7×10÷5'UNION ALL SELECT'5888','8×8-8×5'UNION ALL SELECT'5889','8×9÷(8-5)'UNION ALL SELECT'58810','8+8×10÷5'UNION ALL SELECT'591010','9+10+10-5'UNION ALL SELECT'6666','6+6+6+6'UNION ALL SELECT'6668','(6+6-8)×6'UNION ALL SELECT'6669','6+6×(9-6)'UNION ALL SELECT'66610','6×10-6×6'UNION ALL SELECT'6679','(6+7-9)×6'UNION ALL SELECT'66710','6-(7-10)×6'UNION ALL SELECT'6688','6×8÷(8-6)'UNION ALL SELECT'6689','(8-6)×9+6'UNION ALL SELECT'66810','(6+8-10)×6'UNION ALL SELECT'66910','(9-6)×10-6'UNION ALL SELECT'67710','(7+7-10)×6'UNION ALL SELECT'6789','8÷(9-7)×6'UNION ALL SELECT'67810','8×(7-10+6)'UNION ALL SELECT'6799','(7+9)×9÷6'UNION ALL SELECT'671010','(10-7)×10-6'UNION ALL SELECT'6888','8+8×(8-6)'UNION ALL SELECT'6889','(8+8)×9÷6'UNION ALL SELECT'68810','8×(8+10)÷6'UNION ALL SELECT'6899','8×(9+9)÷6'UNION ALL SELECT'68910','9×(10-8)+6'UNION ALL SELECT'69910','9+9×10÷6'UNION ALL SELECT'6101010','10+10+10-6'UNION ALL SELECT'77910','10+(9-7)×7'UNION ALL SELECT'7889','8+8×(9-7)'UNION ALL SELECT'78810','8×10-8×7'UNION ALL SELECT'78910','8×9÷(10-7)'UNION ALL SELECT'781010','10-(8-10)×7'UNION ALL SELECT'88810','8+8×(10-8)' )k), tt AS( SELECT  id,c1,c2,c3,c4,  CASE WHEN c1>=c2 AND c2>=c3 AND c3>=c4 THEN CONCAT(c4,c3,c2,c1)     WHEN c1>=c2 AND c2>=c4 AND c4>=c3 THEN CONCAT(c3,c4,c2,c1)    WHEN c1>=c3 AND c3>=c2 AND c2>=c4 THEN CONCAT(c4,c2,c3,c1)    WHEN c1>=c3 AND c3>=c4 AND c4>=c2 THEN CONCAT(c2,c4,c3,c1)    WHEN c1>=c4 AND c4>=c3 AND c3>=c2 THEN CONCAT(c2,c3,c4,c1)    WHEN c1>=c4 AND c4>=c2 AND c2>=c3 THEN CONCAT(c3,c2,c4,c1)    WHEN c2>=c1 AND c1>=c3 AND c3>=c4 THEN CONCAT(c4,c3,c1,c2)    WHEN c2>=c1 AND c1>=c4 AND c4>=c3 THEN CONCAT(c3,c4,c1,c2)    WHEN c2>=c3 AND c3>=c4 AND c4>=c1 THEN CONCAT(c1,c4,c3,c2)    WHEN c2>=c3 AND c3>=c1 AND c1>=c4 THEN CONCAT(c4,c1,c3,c2)    WHEN c2>=c4 AND c4>=c1 AND c1>=c3 THEN CONCAT(c3,c1,c4,c2)    WHEN c2>=c4 AND c4>=c3 AND c3>=c1 THEN CONCAT(c1,c3,c4,c2)    WHEN c3>=c1 AND c1>=c2 AND c2>=c4 THEN CONCAT(c4,c2,c1,c3)    WHEN c3>=c1 AND c1>=c4 AND c4>=c2 THEN CONCAT(c2,c4,c1,c3)    WHEN c3>=c2 AND c2>=c1 AND c1>=c4 THEN CONCAT(c4,c1,c2,c3)    WHEN c3>=c2 AND c2>=c4 AND c4>=c1 THEN CONCAT(c1,c4,c2,c3)    WHEN c3>=c4 AND c4>=c1 AND c1>=c2 THEN CONCAT(c2,c1,c4,c3)    WHEN c3>=c4 AND c4>=c2 AND c2>=c1 THEN CONCAT(c1,c2,c4,c3)    WHEN c4>=c3 AND c3>=c2 AND c2>=c1 THEN CONCAT(c1,c2,c3,c4)    WHEN c4>=c3 AND c3>=c1 AND c1>=c2 THEN CONCAT(c2,c1,c3,c4)    WHEN c4>=c2 AND c2>=c3 AND c3>=c1 THEN CONCAT(c1,c3,c2,c4)    WHEN c4>=c2 AND c2>=c1 AND c1>=c3 THEN CONCAT(c3,c1,c2,c4)    WHEN c4>=c1 AND c1>=c2 AND c2>=c3 THEN CONCAT(c3,c2,c1,c4)    WHEN c4>=c1 AND c1>=c3 AND c3>=c2 THEN CONCAT(c2,c3,c1,c4)        END gs     FROM poker24.cards)SELECT tt.id,tt.c1,tt.c2,tt.c3,tt.c4,t.ss FROM tt LEFT JOIN t ON tt.gs = t.s

《数据库编程大赛》

下一次再聚!

感谢大家对本次《数据库编程大赛》的关注和支持,欢迎加入技术交流群,更多精彩活动不断,我们下次再相聚!

你可能感兴趣的:(云数据库技术,SQL,开发,etl工程师,数据库,数据仓库,mysql,云计算,sql,chatgpt)