0
Personal I’m just with a doubt, about how the mysql select works.
Select SUM(IF('','',''))
I’m using it but I don’t really know how it works
0
Personal I’m just with a doubt, about how the mysql select works.
Select SUM(IF('','',''))
I’m using it but I don’t really know how it works
5
Just imagine your example: SUM(IF(debito_credito_financeiro = 'D', valor_financeiro, 0)) AS debito,
The syntax is
IF(condition, return if true, return if false)
That is, if debito_credito_financeiro
has the value of D
, then he’ll add the valor_financeiro
otherwise, it will add 0
.
"IF(debito_credito_financial = 'C', financial valuation, -financial valuation)" in this case the first value is positive and the second negative
1
Let’s say I want to count how many branches in my branch chart have the larger 20 code.
I could write:
select sum( if ( cod_filial > 21, 1, 0 )) from tabelafilais
or wanted to count how many records start with 58 in the local table:
select sum( if ( cod_local like '58%', 1, 0 )) from tabela_locais
Browser other questions tagged mysql select if
You are not signed in. Login or sign up in order to post.
You can show what you have sff?
– Pedro Luzio