Welcome Guest, Not a member yet? Register   Sign In
Problem with query on sqlsrv
#1

We have a problem result of this query.
On this query we have 4 column on this have 3 don't have column name. (This is a problem), When we put the column name this return everything correct but when we don't column name don't return nothing.

On codeigniter have any workaround to put dynamically the name on columns? We collect this query to other system and is impossible make change on that.

$res = $this->DB2->query("SELECT cast(VENDAS_ANO_ATUAL as money),cast(VENDAS_ANO_ANTERIOR as money), cast(cast(CASE WHEN VENDAS_ANO_ANTERIOR = 0 THEN 0 ELSE ((VENDAS_ANO_ATUAL - VENDAS_ANO_ANTERIOR) / VENDAS_ANO_ANTERIOR) * 100 END as int) as varchar) + '%' AS PERCENTAGEM, case when VENDAS_ANO_ANTERIOR < VENDAS_ANO_ATUAL then '' else case when VENDAS_ANO_ANTERIOR> VENDAS_ANO_ATUAL then '' else '' end end FROM ( SELECT SUM(CASE WHEN Ano = YEAR(GETDATE()) THEN TotalLiqMBase ELSE 0 END) AS VENDAS_ANO_ATUAL, SUM(CASE WHEN Ano = YEAR(GETDATE())-1 THEN TotalLiqMBase ELSE 0 END) AS VENDAS_ANO_ANTERIOR FROM AcumuladosVendas (NOLOCK) JOIN DocumentosVenda ON DocumentosVenda.Documento=AcumuladosVendas.TipoDoc WHERE AcumuladosVendas.VENDEDOR IN (1) AND DocumentosVenda.TipoDocumento = 4 ) AS DATA")->result();

Thanks
Reply


Messages In This Thread
Problem with query on sqlsrv - by renatoribeiro - 09-13-2018, 02:16 AM
RE: Problem with query on sqlsrv - by php_rocs - 09-13-2018, 07:32 AM
RE: Problem with query on sqlsrv - by ciadmin - 09-13-2018, 09:52 AM
RE: Problem with query on sqlsrv - by michalsn - 09-13-2018, 10:22 AM
RE: Problem with query on sqlsrv - by php_rocs - 09-13-2018, 01:09 PM
RE: Problem with query on sqlsrv - by michalsn - 09-14-2018, 10:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB