Author |
Topic |
hromagda
Starting Member
1 Post |
Posted - 2013-08-12 : 09:39:15
|
Hello all I would like to get one condition into my query. I need to return numbers of contracts - in our db named[U_KELAR_CSML] from the table [@BOY_ABON] where... and now the requested condition...on contracts there are field 'date of activation' - U_BOY_FROM and 12 checkboxes for particular months(U_BOY_Jan; U_BOY_Feb, U_BOY-Mar,...), where you can tick how are invoices paid (monthly, quartely, once a half an year or once a year)and I need to get condition for all contracts paid once a half an year and more - difference between U_BOY_FROM and way of invoice paying is bigger than half an year. Could you help me with this condition?Thank you |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-08-12 : 11:20:01
|
Something like this:[CODE]DECLARE @BOY_ABON TABLE (AccNo INT, U_BOY_Jan INT, U_BOY_Feb INT, U_BOY_Mar INT, U_BOY_Apr INT, U_BOY_May INT);INSERT INTO @BOY_ABONSELECT 1, 0,0,0,0,0UNION SELECT 2, 1,0,0,0,0UNION SELECT 3, 1,1,0,0,0UNION SELECT 4, 1,1,1,0,0UNION SELECT 5, 1,1,1,1,0UNION SELECT 6, 1,1,1,1,1;SELECT AccNo, (U_BOY_Jan + U_BOY_Feb + U_BOY_Mar + U_BOY_Apr + U_BOY_May) as NumPayments FROM @BOY_ABON WHERE (U_BOY_Jan + U_BOY_Feb + U_BOY_Mar + U_BOY_Apr + U_BOY_May) > 2;[/CODE] |
|
|
|
|
|