SELECT P.PK_SUPPLIER,
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'YYYY') "Y",
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'MM') "M",
'第'||to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'Q')||'季度' "JD",
SUM(P.NTOTALORIGMNY) AS NOTALORIGMNY,
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM') "BILLDATE",
PK_GROUP,
PK_ORG
FROM PO_ORDER P
GROUP BY P.PK_SUPPLIER,
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'YYYY'),
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'MM'),
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'Q'),
to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM'),
PK_GROUP,
PK_ORG
ORDER BY BILLDATE DESC;
报错:
数据库存值:2015-08-01 13:00:17 使用以下查询 报错 小时值必须介于1~12之间
SELECT to_char(to_date(p.dbilldate,'yyyy-mm-dd hh:mi:ss'),'Q') FROM PO_ORDER p ;
原因:数据库为24H的 查询使用为12 所以报错 解决:
SELECT to_char(to_date(p.dbilldate,'yyyy-mm-dd hh24:mi:ss'),'Q') FROM PO_ORDER p ;
https://www.cnblogs.com/fery/p/5286883.html
https://blog.csdn.net/Winne_Shen/article/details/79461162