Hi gokuldas,
Refer below SQL Query.
SQL
SELECT
u.username as TransactionWith
,c.UserId
,Credit = CASE WHEN c.Type = '0' THEN '0' Else (Amount) End
,Debit = CASE WHEN c.Type = '0' THEN -(Amount) Else '0' End
,(SELECT us.username FROM Tbl_users us WHERE us.UserId = c.CreditFrom) as Reference
,Dt as Date
FROM Tbl_Credit c ,Tbl_users u
WHERE u.Id = c.UserId AND u.Id = 29
UNION
SELECT DISTINCT Top 10
u.username as TransactionWith
,c.UserId
,Credit = CASE WHEN c.Type = '0' THEN (Amount) Else 0 End
,Debit = CASE WHEN c.Type = '0' THEN 0 Else -(Amount) End
,(SELECT us.username FROM Tbl_users us WHERE us.UserId = c.CreditFrom) as Reference
,Dt as Date
FROM Tbl_Credit c,Tbl_users u
WHERE u.Id = c.UserId AND c.Type='1' AND u.Id = 29