0
我有以下查詢:甲骨文複雜的SQL SELECT查詢
SELECT SUM (UNCOLLECTED)
FROM LIQUIDATIONSDETAILS LD
WHERE LD.COMPANYID = L.COMPANYID
AND LD.GROUPID = L.GROUPID
AND LD.PERIODID = L.PERIODID
AND LD.FORMTYPE IN (1, 2, 3)
我需要的時候L.PERIODID > '2013-2014'
那麼LD.FORMTYPE IN (1,2,3,4)
其他LD.FORMTYPE IN (1,2,3)
什麼想法?
基於時間段怎麼能比「2013-2014」更大,這將等於「-1」,它必須大於2013年或2014年? –
Mathieu的PERIODID是一個Varchar列,值的例子是:'2013-2014' '2014-2015'等 – Giorgos
我不擅長與甲骨文,但會這樣嗎? (LD)是LD.COMPANYID = L.COMPANYID和LD.GROUPID = L.GROUPID AND((LD.PERIODID = L.PERIODID AND LD.FORMTYPE IN(1,2,3,4)AND LD) .PERIODID>'2013-2014')或(LD.PERIODID = L.PERIODID AND LD.FORMTYPE IN(1,2,3)AND LD.PERIODID <'2013-2014'))' – venkatKA