I imagine the following revised query for your requirement which does not join to the statement table as such a join will probably multiply the number of rows and therefore produce errors in the results.
SELECT
merchant.merchantname 'MerchantName'
, COUNT(t.transactionid) 'NoofTransaction'
, SUM(t.transactionamount) 'TotalAmount'
, (
SELECT
statement.statementbalance
FROM statement
WHERE t.transactionid = statement.transactionid
ORDER BY
some_date_column DESC LIMIT 1
)
AS 'BalanceRemaining'
FROM merchant
INNER JOIN `transaction` t ON merchant.merchantid = t.merchantid
WHERE t.transactiondate = '2018-01-15'
GROUP BY
merchant.merchantid
ORDER BY
merchant.merchantid ASC
;
NOTE, that the date column(s) to use for ordering ("last inserted") isn't given in the question.
Also I have reversed the table relationship. There isn't much point in using right joins in my view as it is almost always easier to structure the query to use the "from table" so that subsequent joins never need a right join. In this particular case an outer join of any form does not appear to be needed due to the where clause, so an inner join is used instead.
added: To list all merchants:
SELECT
merchant.merchantname 'MerchantName'
, COUNT(t.transactionid) 'NoofTransaction'
, SUM(t.transactionamount) 'TotalAmount'
, (
SELECT
statement.statementbalance
FROM statement
WHERE t.transactionid = statement.transactionid
ORDER BY
some_date_column DESC LIMIT 1
)
AS 'BalanceRemaining'
FROM merchant
LEFT JOIN `transaction` t ON merchant.merchantid = t.merchantid
AND t.transactiondate = '2018-01-15'
GROUP BY
merchant.merchantid
ORDER BY
merchant.merchantid ASC
;
statement? What is the actual column name? what is/are the column/s that determine "last inserted" result?