gpt4 book ai didi

sql oracle 当前月份

转载 作者:行者123 更新时间:2023-12-04 03:24:23 27 4
gpt4 key购买 nike

我能够生成一个查询,该查询将为我提供 10 月份的自动保存信息。

但是,我正在尝试对其进行修改,以便我可以获得当前月份的通用查询,这样我就不必每次都更新查询。

有什么想法吗?

下面是我 2015 年 10 月的查询

SELECT
c.invoicenum,c.invoicedate, c.vendorname,c.account, c.invoiceid , decode(nvl(b.invoiceid,-1),-1,'No','Yes') "Approved",
decode(nvl(b.invoiceid,-1),-1,'No',nvl(a.invoiceid,-2),'No','Yes') "Auto Saved for Approval"
FROM
(SELECT d.invoicenum,d.invoicedate, v.vendorname,d.account, d.invoiceid FROM invoice d, vendor v
WHERE d.invoicestatus in (1,5,7,8) AND v.vendorid=d.vendorid AND v.status=0 AND to_char(d.dateentered,'MMYY')='1015') c,

(SELECT d.invoicenum,d.invoicedate, v.vendorname,d.account, d.invoiceid FROM invoice d, vendor v
WHERE d.invoicestatus in (7,8) AND v.vendorid=d.vendorid AND v.status=0 AND to_char(d.dateentered,'MMYY')='1015') b,

(SELECT d.invoicenum,d.invoicedate, v.vendorname,d.account, d.invoiceid FROM invoicehistory b, invoice d, vendor v
WHERE operationtype=21 AND d.invoicestatus in (7,8) AND b.invoiceid =d.invoiceid AND to_char(d.dateentered,'MMYY')='1015' AND v.vendorid=d.vendorid and v.status=0) a

WHERE c.invoiceid=b.invoiceid and c.invoiceid=a.invoiceid(+) and a.invoiceid is null;

最佳答案

听起来你只是想替换

to_char(d.dateentered,'MMYY')='1015'

trunc( d.dateEntered, 'MM' ) = trunc( sysdate, 'MM' )

sysdate返回当前日期。 trunc(<<date>>, 'MM')返回给定输入当月第一天的午夜。

关于sql oracle 当前月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33555291/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com