-1
I’m doing a search at the bank.
On the table, I have 6 dates: data1, data2, data3, data4, data5 e data6.
I’m sweeping these dates to find out which one matches the current month.
This is already being done:
...
WHERE
YEAR(data1) = YEAR(CURRENT_DATE) AND MONTH(data1) = MONTH(CURRENT_DATE) OR
YEAR(data2) = YEAR(CURRENT_DATE) AND MONTH(data2) = MONTH(CURRENT_DATE) OR
YEAR(data3) = YEAR(CURRENT_DATE) AND MONTH(data3) = MONTH(CURRENT_DATE) OR
YEAR(data4) = YEAR(CURRENT_DATE) AND MONTH(data4) = MONTH(CURRENT_DATE) OR
YEAR(data5) = YEAR(CURRENT_DATE) AND MONTH(data5) = MONTH(CURRENT_DATE) OR
YEAR(data6) = YEAR(CURRENT_DATE) AND MONTH(data6) = MONTH(CURRENT_DATE)
ORDER BY cliente, tipo, id
Now I need to find out which date (1,2,3,4,5 or 6) that fell to catch that number search in another field called valorX
, where x is the value of the date field (1,2,3,4,5 or 6) and concatenate and return how many reals are in that field.
Somebody help me with this logic?
Already evaluated the use of CASE / WHEN?
– anonimo
Not yet. I don’t really know how to do it! My difficulty here is logic. I think!
– Carlos Rocha