SELECT max(id),  (SELECT Ledger_Name FROM $master_db.Ledger_Master where DbName = FromDBName) as 'From Ledger',TypeOfData as Type, max(Time_Stamp) as 'Received Time',  (case when min(Action) = 1001 then 'NEW' when min(Action) = 1002 then 'UPDATE' when min(Action) = 1003 then 'DELETE' end) as Action,  case when TypeOfData = 'Voucher' then  json_extract(Notification_Data, '$.Voucher_Type')  when TypeOfData = 'Inventory Item' then  json_extract(Notification_Data, '$.BaseItem.Item_Name') when TypeOfData = 'Inventory Group' then  json_extract(Notification_Data, '$.GroupName') when TypeOfData = 'Brand' then  json_extract(Notification_Data, '$.Brand_Name') when TypeOfData = 'UOM' then  json_extract(Notification_Data, '$.UomName') when TypeOfData = 'Acknowledgement' then  concat( json_extract(Notification_Data, '$.Status'))  end as Description  FROM ReceiveChannel WHERE Status = 0 GROUP BY Generated_TransactionID