I need to write a query that returns a Column Dynamically. For example I have a table tblTest with columns:
Id, Name, Type, Amount 1, Receipt, Cash 100
Hej,
Hope i got you right.
select name, type, sum(CASE WHEN Type in (select DISTINCT sub.type from tblTest sub) THEN Amount ELSE 0 END) as "sum" from tblTest group by name, type;