mysql写一个sql吧一套试卷1-8每套卷查一套都查出来没有数据的给null 按照时间倒叙!


假设试卷数据存储在名为`papers`的表中,字段包括`paper_id`(试卷编号)和`time`(时间)。以下是按照时间倒序查询每套试卷的SQL语句: ```sql SELECT CASE paper_id WHEN 1 THEN '试卷1' WHEN 2 THEN '试卷2' WHEN 3 THEN '试卷3' WHEN 4 THEN '试卷4' WHEN 5 THEN '试卷5' WHEN 6 THEN '试卷6' WHEN 7 THEN '试卷7' WHEN 8 THEN '试卷8' END AS `试卷`, IFNULL(time, NULL) AS `时间` FROM papers WHERE paper_id BETWEEN 1 AND 8 ORDER BY time DESC; ``` 这个查询语句将返回一个结果集,其中每行包含一个试卷和对应的时间(如果有)。如果试卷没有时间数据,则时间将以`NULL`显示。结果集按时间倒序排列。以试卷1-8分别代表`试卷1`,`试卷2`,`试卷3`,`试卷4`,`试卷5`,`试卷6`,`试卷7`和`试卷8`。 示例中的`papers`是假设的表名,也可以根据实际情况进行更改。 [2024-05-20 08:09:44 | AI写代码神器 | 305点数解答]
相关提问
- CREATE TABLE `sys_role` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', `parent_id` bigint(20) DEFAULT '0' COMMENT '上级ID(0表示没有上级)', `role_name` varchar(30) DEFAULT '' COMMENT '角色名称', `sort` int(11) DEFAULT '1' COMMENT '排序', `status` tinyint(1) DEFAULT NULL COMMENT '状态:0无效 1有效', `remarks` varchar(100) DEFAULT NULL COMMENT '备注描述', `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', `create_by` bigint(20) DEFAULT NULL COMMENT '创建人', `update_time` timestamp NULL DEFAU(168点数解答 | 2025-04-10 14:39:47)98
- - ItemId: 12720 #道具id A级赛车 雷诺 ItemNum: 1 #数量 ObtainTime: 1 #时间 AvailPeriod: -1 #0显示数量 -1显示永久 - ItemId: 127758 #道具id 宠物 冰凤 ItemNum: 1 #数量 ObtainTime: 1 #时间 AvailPeriod: -1 #0显示数量 -1显示永久 - ItemId: 21980 #道具id 效率宝珠LV4 ItemNum: 100 #数量 ObtainTime: 1 #时间 AvailPeriod: 0 #0显示数量 -1显示永久 - ItemId: 21986 #道具id 重生宝珠LV4 ItemNum: 100 #数量 ObtainTime: 1 #时间 AvailPeriod: 0 #0显示数量 -1显示永久 这种文本文件如何用易语言读入并显示到超级列表框内 (571点数解答 | 2025-08-23 20:54:40)47
- - ItemId: 12720 #道具id A级赛车 雷诺 ItemNum: 1 #数量 ObtainTime: 1 #时间 AvailPeriod: -1 #0显示数量 -1显示永久 - ItemId: 127758 #道具id 宠物 冰凤 ItemNum: 1 #数量 ObtainTime: 1 #时间 AvailPeriod: -1 #0显示数量 -1显示永久 - ItemId: 21980 #道具id 效率宝珠LV4 ItemNum: 100 #数量 ObtainTime: 1 #时间 AvailPeriod: 0 #0显示数量 -1显示永久 - ItemId: 21986 #道具id 重生宝珠LV4 ItemNum: 100 #数量 ObtainTime: 1 #时间 AvailPeriod: 0 #0显示数量 -1显示永久 这种文本文件如何用易语言读入并显示到超级列表框内,并且可以增加新的一样的文本(1317点数解答 | 2025-08-23 20:58:40)43
- pandas读取文件,文件某一列分组,条件为列数据字段中包含“一级”为一组,没有“一级”的为一组,将pandas读取到的文件按地市映射表分为各地市文件,再将这个文件当作邮件附件,邮件正文为某地市,有“一级”多少,没有“一级”多少,语言方向:Python,系统环境:Windows(459点数解答 | 2024-12-25 01:17:06)131
- ```cpp #include <iostream> using namespace std; struct node { int data; node* link; node(int x) : data(x), link(null) {} }; // 查找最大节点及其前一个节点 void findmaxandprev(node* list, node*& maxnode, node*& prevmax) { node* curr = list; maxnode = list; prevmax = null; node* prev = null; while (curr!= null) { if (curr->data > maxnode->data) { maxnode = curr; prevmax = prev; } prev = curr; curr = curr->link; } } // 将最大节点移到链表末尾 void movemaxtoend(node*& list) { node* maxnode = null; node* prevmax = null;(549点数解答 | 2024-10-14 22:55:13)182
- #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct sqlist //单链表结构体 { int data; struct sqlist *next; //指针域 }sqlist; void initlist (sqlist *l, sqlist *m, sqlist *n, sqlist *h) { //todo list yes l->next = null; m->next = null; n->next = null; h->next = null; } void emp(sqlist *l) { if (l->next==null) //todo list)yes printf("链表为空表。\n"); else printf("链表为非空表。\n"); } void length(sqlist *l) { sqlist *p; int length = 0; p=l->next; while(p!=null)(428点数解答 | 2024-10-23 23:09:51)159
- #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct sqlist //单链表结构体 { int data; struct sqlist *next; //指针域 }sqlist; void initlist (sqlist *l, sqlist *m, sqlist *n, sqlist *h) { //todo list yes l->next = null; m->next = null; n->next = null; h->next = null; } void emp(sqlist *l) { if (l->next==null) //todo list)yes printf("链表为空表。\n"); else printf("链表为非空表。\n"); } void length(sqlist *l) { sqlist *p; int length = 0; p=l->next; while(p!=null) { length++; p=p->next; } //todo list(345点数解答 | 2024-10-23 23:11:22)150
- CREATE TABLE `categories` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '分类名称', `parent_id` bigint NOT NULL COMMENT '父分类ID', `description` text COMMENT '分类描述', `created_by` bigint NOT NULL COMMENT '创建者ID', `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET(1733点数解答 | 2025-06-18 01:54:30)58
- [{id:1,src:'/1.jpg'},{id:2,src:'null'},{id:3,src:'/2.jpg'},{id:4,src:'null'},{id:5,src:'/3.jpg'},{id:6,src:'null'}] js转换[{id:1,src:'/1.jpg'},{id:2,src:'/2.jpg'},{id:3,src:'/3.jpg'},{id:4,src:'null'},{id:5,src:'{id:4,src:'null'},'},{id:6,src:'null'}](680点数解答 | 2025-08-04 17:09:03)62
- [ { "id": 1, "parentId": 0, "spread": true, "title": "数据", "path": "", "status": 1, "sort": 1, "parentTitle": null, "children": [ { "id": 2, "parentId": 1, "spread": false, "title": "项目-知识库", "path": "/cms/data/questionprolist.html", "status": 1, "sort": 2, "parentTitle": "数据", (603点数解答 | 2025-04-15 22:48:51)101
- 数据库表结构: 我们已经有以下的数据库表结构来存储书籍信息: create table `books` ( `id` int(11) not null auto_increment, `title` varchar(255) not null, `author` varchar(255) not null, `price` decimal(10, 2) not null, `stock` int(11) not null, primary key (`id`) ) engine=innodb default charset=utf8mb4; 1. 请编写一个bookcontroller 包含方法findall(),该方法使用 @responsebody 注解返回一个包含书籍信息的 list对象,并确保返回的是json格式。 2. 编写一个 bookservice 接口定义了findall()方法,用于查询所有书籍。现在需要新建实现类 bookserviceimpl, 并实现findall()方法,将bookserviceimpl注入到控制器中 3. 编写数据(651点数解答 | 2024-12-08 14:19:12)246
- 数据库表结构: 我们已经有以下的数据库表结构来存储书籍信息: create table `books` ( `id` int(11) not null auto_increment, `title` varchar(255) not null, `author` varchar(255) not null, `price` decimal(10, 2) not null, `stock` int(11) not null, primary key (`id`) ) engine=innodb default charset=utf8mb4; 1. 请编写一个bookcontroller 包含方法findall(),该方法使用 @responsebody 注解返回一个包含书籍信息的 list对象,并确保返回的是json格式。 2. 编写一个 bookservice 接口定义了findall()方法,用于查询所有书籍。现在需要新建实现类 bookserviceimpl, 并实现findall()方法,将bookserviceimpl注入到控制器中 3. 编写数据库访问接口bookmappe(254点数解答 | 2024-12-08 14:23:56)269