Hi.
I can do this with union but I wanted to ask if it is possible woth a left join
I have 2 tables tblDWTicket and tblDWBookingFee . tblDWTicket will always have a transaction with values tblDWBookingFee somethimes
So doing this:
will give me this:
Doing this:
Will give me this:
But trying to add them:
Will give me this:
Ultimately I would like to sum the values by doing the below but I'm stuck at the above as I would be expecting zeros on the no value lines but I don't get them.
The gross that would be tried:
That will give me a completely wrong result:
I can union or other mumbo jumbo but can't it be done with a left join? Why do i get values instead of nulls?
I can do this with union but I wanted to ask if it is possible woth a left join
I have 2 tables tblDWTicket and tblDWBookingFee . tblDWTicket will always have a transaction with values tblDWBookingFee somethimes
So doing this:
Code:
select T.TransNumber, isnull(T.GrossValue,0)
from tblDWTicket T
where T.SystemCode = 'V'
and t.TransStatus = 'C'
and t.TransNumber = 110520
Code:
TransNumber (No column name)
110520 -8,50
110520 -8,50
110520 -8,50
Code:
select BF.TransNumber, IsNull(BF.GrossValue, 0)
from tblDWBookingFee BF
where isnull( BF.TransStatus,'0') in ('C')
and BF.TransNumber = 110520
Code:
TransNumber GrossValue
110520 -1,00
110520 -1,00
110520 -1,00
Code:
select T.TransNumber,T.GrossValue, IsNull(BF.GrossValue, 0)
from tblDWTicket T
Left join tblDWBookingFee BF on BF.TransNumber = T.TransNumber
where T.SystemCode = 'V'
and t.TransStatus = 'C'
and isnull( BF.TransStatus,'0') in ('C')
and t.TransNumber = 110520
Code:
TransNumber GrossValue GrossValue
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
110520 -8,50 -1,00
The gross that would be tried:
Code:
select T.TransNumber,sum((T.GrossValue + IsNull(BF.GrossValue, 0))) as Total
from tblDWTicket T
Left join tblDWBookingFee BF on BF.TransNumber = T.TransNumber
where T.SystemCode = 'V'
and t.TransStatus = 'C'
and isnull( BF.TransStatus,'0') in ('C')
and t.TransNumber = 110520
group by T.TransNumber
Code:
TransNumber Total
110520 -85,50