df-drills pandas · Polars · DuckDB SQL · DuckDB Relational 题目列表 登录

指定列顺序

简单 01-select 选择与投影 selectcolumn-order

调整订单表的列顺序:把 order_ts、order_id 依次放在最前面,其余列保持它们在原表中的先后顺序,接在后面。

  • 本题检查列顺序。
  • 其余列不要手写:用“除了这两列之外的所有列”来表达。
  • 所有行都保留,null 原样保留。

输入

  • orders(order_id, customer_id, order_ts, status, channel)

输出

列依次为 order_ts, order_id, customer_id, status, channel,行顺序不限。

输入表 (case base,共 2 个 case:base、small)

orders shop/orders
#order_idint64customer_idint64order_tsdatetimestatusstringchannelstring
1 1001 39 2026-01-01 19:38:00 paid app
2 1002 16 2026-01-17 14:07:00 paid app
3 1003 4 2026-01-08 15:40:20 cancelled web
4 1004 2 2026-05-23 10:48:58 paid null
5 1005 12 2026-06-22 11:07:22 paid store
6 1006 17 2026-08-15 05:15:25 paid web
7 1007 9 2026-06-11 01:00:32 refunded store
8 1008 45 2026-09-19 20:47:10 paid web
9 1009 2 2025-10-05 04:53:38 paid app
10 1010 4 2026-02-19 01:39:54 paid app
11 1011 28 2026-03-05 03:04:45 refunded store
12 1012 2 2026-08-01 07:09:17 paid web
13 1013 26 2026-01-22 03:48:14 refunded store
14 1014 2 2026-02-09 01:41:41 paid app
15 1015 5 2026-08-03 19:49:04 refunded web
16 1016 26 2026-02-16 00:43:43 refunded app
17 1017 9 2025-12-06 04:48:57 pending app
18 1018 999 2026-05-19 12:13:43 paid store
19 1019 26 2026-02-05 15:02:26 paid store
20 1020 44 2025-11-24 11:19:00 cancelled web
显示前 20 行,共 200 行

期望输出 (case base,行顺序不限,列顺序要一致)

#order_tsDatetime(time_unit='us', time_zone=None)order_idInt64customer_idInt64statusStringchannelString
1 2026-01-01 19:38:00 1001 39 paid app
2 2026-01-17 14:07:00 1002 16 paid app
3 2026-01-08 15:40:20 1003 4 cancelled web
4 2026-05-23 10:48:58 1004 2 paid null
5 2026-06-22 11:07:22 1005 12 paid store
6 2026-08-15 05:15:25 1006 17 paid web
7 2026-06-11 01:00:32 1007 9 refunded store
8 2026-09-19 20:47:10 1008 45 paid web
9 2025-10-05 04:53:38 1009 2 paid app
10 2026-02-19 01:39:54 1010 4 paid app
11 2026-03-05 03:04:45 1011 28 refunded store
12 2026-08-01 07:09:17 1012 2 paid web
13 2026-01-22 03:48:14 1013 26 refunded store
14 2026-02-09 01:41:41 1014 2 paid app
15 2026-08-03 19:49:04 1015 5 refunded web
16 2026-02-16 00:43:43 1016 26 refunded app
17 2025-12-06 04:48:57 1017 9 pending app
18 2026-05-19 12:13:43 1018 999 paid store
19 2026-02-05 15:02:26 1019 26 paid store
20 2025-11-24 11:19:00 1020 44 cancelled web
21 2026-06-29 17:32:41 1021 18 refunded app
22 2026-06-23 06:27:44 1022 1 cancelled app
23 2026-07-24 02:09:45 1023 46 refunded web
24 2026-02-26 18:42:02 1024 47 paid null
25 2026-07-05 07:41:49 1025 34 cancelled web
26 2025-11-24 08:15:00 1026 18 paid web
27 2026-05-22 08:52:21 1027 42 paid web
28 2026-01-12 18:12:02 1028 36 paid app
29 2026-03-03 14:01:10 1029 18 paid web
30 2026-06-12 16:22:09 1030 5 paid store
31 2026-02-14 10:30:00 1031 5 paid app
32 2026-02-14 13:30:00 1032 5 paid web
33 2026-02-14 16:30:00 1033 5 paid store
34 2026-02-14 10:30:00 1034 5 paid app
35 2025-12-25 18:50:00 1035 24 refunded null
36 2026-01-16 01:42:07 1036 14 refunded app
37 2026-03-08 19:28:41 1037 38 pending store
38 2025-12-18 09:01:58 1038 9 paid store
39 2025-09-12 08:26:19 1039 2 paid web
40 2026-02-11 15:04:00 1040 12 cancelled web
41 2026-04-22 15:13:08 1041 32 paid app
42 2025-10-28 14:44:18 1042 35 cancelled web
43 2026-01-05 21:57:00 1043 26 paid store
44 2026-02-09 18:36:53 1044 6 paid store
45 2026-01-23 07:06:47 1045 45 cancelled web
46 2026-06-30 01:58:03 1046 22 paid web
47 2026-01-09 09:26:50 1047 8 paid app
48 2025-12-14 00:07:09 1048 5 paid app
49 2026-07-31 23:48:12 1049 44 paid app
50 2026-01-05 17:34:00 1050 34 refunded null
显示前 50 行,共 200 行