20金币
本帖最后由 凄美地 于 2024-7-24 16:24 编辑
postgresql数据库:SELECT
SUM( CASE WHEN a."industrialOutputValue" > b."industrialOutputValue" THEN 1 ELSE 0 END ) AS greater_count,
SUM( CASE WHEN a."industrialOutputValue" < b."industrialOutputValue" THEN 1 ELSE 0 END ) AS lesser_count
FROM
( SELECT @type as "industrialOutputValue" , "creditCode" FROM hs_preliminary_list WHERE year= @year AND "creditCode" IS NOT NULL ) a
JOIN ( SELECT @type as "industrialOutputValue", "creditCode" FROM hs_preliminary_list WHERE year= @year-1 AND "creditCode" IS NOT NULL ) b ON a."creditCode" = b."creditCode"; 为什么这样查出来不一样呢 ,有擅长这方面的大佬看看吗;发了一个demo以及demo测试图片,不过demo是内建库,会直接因为@引用参数产生“”报错;实际环境是postgresql
|
最佳答案
查看完整内容
大佬,看了下咱们的demo, 这个场景的话,我们就需要勾选“使用公式”然后用excel函数来拼接sql了
|