mysql查询
Posted 武魂95级蓝银草
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql查询相关的知识,希望对你有一定的参考价值。
1.示例1
查询1:
SELECT CASE main_xm_sam31 WHEN ‘02‘ THEN 2 ELSE 1 END AS SPDJ FROM SR_MAIN_BG A WHERE A.PK_SR_MAIN = ‘1162275825622593536‘ AND (SYS_SPDJ = 0 OR SYS_SPDJ = -1)
查询2:
SELECT
count(1) AS ncount,
(
CASE sys_sjbj
WHEN 0 THEN
‘个人发布‘
WHEN 1 THEN
‘组织发布‘
WHEN 2 THEN
‘机构发布‘
ELSE
‘其他‘
END
) AS fblx,
ifnull(
sum(CASE rlzt WHEN 2 THEN 1 ELSE 0 END),
0
) AS xyl,
ifnull(
ROUND(
sum(
TIMESTAMPDIFF(DAY, fbsj, rlsj)
) / sum(CASE rlzt WHEN 2 THEN 1 ELSE 0 END),
1
),
0
) AS pjrlsj
FROM
sr_xqfb
WHERE
fbrq LIKE ‘2019%‘
GROUP BY
sys_sjbj
查询3:
SELECT
CASE WHEN mdjlx = ‘0301‘ THEN ‘人道救援‘
WHEN mdjlx = ‘2201‘ THEN ‘低收入家庭免费用电信息‘
WHEN mdjlx = ‘2301‘ THEN ‘低收入家庭优待信息‘
ELSE ‘暂定-农办厅专项救助‘ END AS mdjlx,
sys_xzqh
from sr_main_zdts
以上是关于mysql查询的主要内容,如果未能解决你的问题,请参考以下文章