在toad我试图提取数据,但当我把条件之间的数据输出错误.... 如果我遗失了某些东西,请告诉我....请帮助...
SELECT B.USER_NAME AS CREATED_BY
,A.CREATION_DATE
,C.USER_NAME
,A.LAST_UPDATE_DATE
,A.PFIZER_ITEMCODE
,A.SYSTEM_ITEMCODE AS ORACLE_ITEM_CODE
,A.ITEM_DESCRIPTION
,A.BATCH_NUMBER
,A.MFR_CODE
,A.MFR_DESC AS MFR_DESCRIPTION
,TO_CHAR(A.MFR_DATE, 'DD-MON-YYYY') AS MFR_DATE
,TO_CHAR(A.EXPIRY_DATE, 'DD-MON-YYYY') AS EXPIRY_DATE
,TO_CHAR(A.EFFECTIVE_FROM, 'DD-MON-YYYY') AS EFFECTIVE_FROM
,A.EFFECTIVE_TO
,A.EXCISE AS EXCISE_AMOUNT
,A.EXCISE_RATE
,A.P2S
,A.P2R
,A.MRP
,A.STATE_CODE
,A.STATE
,(CASE SUBSTR(A.SYSTEM_ITEMCODE, 6, 2)
WHEN ('PI')
THEN 'OIP'
WHEN ('PF')
THEN 'OPF'
ELSE 'OWL'
END
) AS LEGAL_ENTITY
FROM xxdhl_pf_batch_pricing A
,fnd_user B
,fnd_user c
WHERE 1 = 1
AND A.CREATED_BY = B.USER_ID
AND A.LAST_UPDATED_BY = C.USER_ID
AND TO_CHAR(A.CREATION_DATE, 'DD-Mon-YYYY') BETWEEN '01-Jan-2015'
AND '08-Jan-2015'
答案 0 :(得分:5)
您应该修复连接语法和格式。简单规则:永远不要在FROM
子句中使用逗号。 始终使用明确的JOIN
语法。
但你的问题可能就是约会。日期比较为日期而不是字符串:
TRUNC(A.CREATION_DATE) BETWEEN DATE '2015-01-01' and DATE '2015-01-08'
DATE
关键字非常方便,因为您可以将日期常量放在ISO标准YYYY-MM-DD格式中。
答案 1 :(得分:0)
上述查询的正确编码是
'AND TRUNC(A.CREATION_DATE) BETWEEN TO_DATE('01-JAN-2015', 'DD-MON-YYYY') AND TO_DATE('08-JAN-2015', 'DD-MON-YYYY')`
的建议
非常有帮助的回答...谢谢所有