做图表怎么能吧下面分开的写到一起啊

 a

SQL 帆软用户YbG5J0kkjo 发布于 2023-6-26 16:40 (编辑于 2023-6-27 08:59)
1min目标场景问卷 立即参与
回答问题
悬赏:0 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
lxy2Lv6中级互助
发布于2023-6-26 16:52

SELECT nvl(SUM(dt.quantity), 0) as qtys,

case when 

runc(SYSDATE) - trunc(t.event_time) > 30

   AND trunc(SYSDATE) - trunc(t.event_time) <= 45

then '30-45天'

when trunc(SYSDATE) - trunc(t.event_time) <=15 then '0-15天'

end as ttype

  FROM fy_product_storage_iron t, hme_pkn_container_dtl dt

 WHERE t.attribute3 = 'IN'

   AND t.pkn_kid = dt.kid

group by 

case when 

runc(SYSDATE) - trunc(t.event_time) > 30

   AND trunc(SYSDATE) - trunc(t.event_time) <= 45

then '30-45天'

when trunc(SYSDATE) - trunc(t.event_time) <=15 then '0-15天'

end

-- 类型我没写完,把条件写在case when里面就行

  • 帆软用户YbG5J0kkjo 帆软用户YbG5J0kkjo(提问者) 排序的时候这样定义成中文会不会乱序
    2023-06-26 17:01 
  • lxy2 lxy2 回复 帆软用户YbG5J0kkjo(提问者) 那就多case when 一个,比如case when trunc(SYSDATE) - trunc(t.event_time) <=15 then 1,然后order by 一下这个就行了
    2023-06-26 17:07 
最佳回答
0
snrtuemcLv8专家互助
发布于2023-6-26 16:43

SELECT nvl(SUM(dt.quantity), 0)

  FROM fy_product_storage_iron t, hme_pkn_container_dtl dt

 WHERE t.attribute3 = 'IN'

   AND t.pkn_kid = dt.kid

   AND trunc(SYSDATE) - trunc(t.event_time) <= 15;

union all

SELECT nvl(SUM(dt.quantity), 0)

  FROM fy_product_storage_iron t, hme_pkn_container_dtl dt

 WHERE t.attribute3 = 'IN'

   AND t.pkn_kid = dt.kid

   AND trunc(SYSDATE) - trunc(t.event_time) > 15

   AND trunc(SYSDATE) - trunc(t.event_time) <= 30;

union all

SELECT nvl(SUM(dt.quantity), 0)

  FROM fy_product_storage_iron t, hme_pkn_container_dtl dt

 WHERE t.attribute3 = 'IN'

   AND t.pkn_kid = dt.kid

   AND trunc(SYSDATE) - trunc(t.event_time) > 30

   AND trunc(SYSDATE) - trunc(t.event_time) <= 45;

union all

SELECT nvl(SUM(dt.quantity), 0)

  FROM fy_product_storage_iron t, hme_pkn_container_dtl dt

 WHERE t.attribute3 = 'IN'

   AND t.pkn_kid = dt.kid

   AND trunc(SYSDATE) - trunc(t.event_time) > 45

  • 2关注人数
  • 196浏览人数
  • 最后回答于:2023-6-27 08:59
    请选择关闭问题的原因
    确定 取消
    返回顶部