the next querysql
select (sum(G325.G303MNTE) + sum(G325.G303MNTD)) as debito, G325.G303UUID as id
from GSCF325 G325
inner join GSCF300 G300 on G300.G300UUID = G325.G303UUID
where G325.G303IMVI = 'P'
and G325.G303DEL = ' ' and G325.G303DBCR='D' and G300.G300CTA = 1104070196
and trunc(G325.G303FEMI) = to_Date('2019/02/13','YYYY-MM-DD')
group by G325.G303UUID
It returns me as a result null
, for both cases, as well as for DEBIT and ID , I have confirmed if the user exists in both tables where I make the comparison, and if they exist, but I think that when returning a null result, the other fields are null as well . If so, I have the question of how to change the results NULL
for another value.
You can use the
coalesce()
e functionsIsNull()
to substitute one null value for another.For example:
coalesce()
In the case
coalesce()
that it is my favorite, because it is part of the SQL standard (which is why it exists in many engines), you can send N parameters and the function will return the first one that is not null, for example:It will return the value of the first field that is not null, in the order of input parameters. It will return
null
if they are all null.IsNull()
IsNull is a SQL Server-specific function, which takes two parameters. Similar to coalesce, returns the first non-null.
It will then return the value of the first field that is not null, or
null
if both are.I am almost sure that the problem is that you do not use lefth, right or full preceded by the join, it does a little blind test with each of those three to see the results, but you should study well how these types of unions work. Here is something very summarized...: http://www.tutorialesprogramacionya.com/oracleya/temarios/descripcion.php?cod=207&punto=1&inicio=