向Mysql表1的A,B,C三列插入数据,D列根据C列数据生成降序排序,用存储过程怎么写?
发布网友
发布时间:2022-04-15 04:18
我来回答
共3个回答
热心网友
时间:2022-04-15 05:47
select agentid,sum(good) as good,sum(normal) as normal,sum(bad) as bad
from
(select agentid,1 as good,0 as normal,0 as bad
from A where content=1
union all
select agentid,0 as good,1 as normal,0 as bad
from A where content=2
union all
select agentid,0 as good,0 as normal,1 as bad
from A where content=3
)B
group by agentid
热心网友
时间:2022-04-15 07:05
select a.编号,a.姓名,b.描述 from a left join b on a.评价分数=b.key
热心网友
时间:2022-04-15 08:40
MYSQL中查询表中按字段降序排列的前N条记录模式:
SELECT 字段名[ , 字段名...] FROM 表名 WHERE 条件 LIMIT 数量 ORDER BY 字段名 DESC
例如:
1
select id,name,email from test where age < 19 limit 5 order by id desc;
上面例子从test表查询所有age小于19的按id降序排序的前5条记录的id,name,email信息。
LIMIT*查询数量,ORDER BY指出按什么排序,DESC表示按降序排序。