sql server - Best way to solve SQL if Condition -


i have problem table item

item |begin | in01 | in02 | ..| in12 | out01 | out02 |..|out12 | balance    | 100  | 10   | 20   | ..| 10   |   5   | 10    |..| 5    | 110 

item have begin qty 100 @ first month, , balance qty @ month 12 = 110 balance updating every month

i need call procedure data every month report

sample report month 01   beginning| in |   out | balance                  100  | 10 |   5   | 105          sample report month 02   beginning| in |   out | balance                 105   | 20 |   10  |  115        sample report month 12   beginning    | in |   out | balance            balance month 11   | xx |   xx  |  11 + in - out 

so beginning value = balance last month way make stored procedure simple? not using lot of 'if'

it's better using case ?

need idea.. thanks

u can used case statement avoid if statement

select case when beginning value = balance 1st option else 2nd option test tbltest 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -