Utilities Blog by JuCa Cruz
If it happened to me before, maybe what I've posted here will help you.
Thursday, November 11, 2010
Conditions in One Line
Interesting point, how can I do 1 LINE If statements like in Java:
a==b?true:false
This is the answer:
SELECT ACCT_ORDER.cidb_order_id, (CASE WHEN mtn_order_type = 'E' AND mtn_order_state = 'P' THEN 1 ELSE 0 END)
I'll see on resultset cidb_order_id, 1 or 0 (
segun sea el caso
) The same sentence could be used on UPDATES:
UPDATE CUST_ACCT_ORDER_STATS SET addline_pending_cnt = CASE WHEN addline_pending_cnt - my_add_count < 0 THEN 0 ELSE addline_pending_cnt - my_add_count END WHERE cust_id = my_cust_id AND acct_num = my_acct_num;
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)