1

My SQL query is:

SELECT SUM([CurrentAmount]) AS Sums, Description 
FROM [xyz] 
WHERE CheckDate = '20191129' 
GROUP BY Description

it results in this output:

| Sums | Description |
| ---- | ----------- |
|  122 | abc         |
|  233 | xyz         |

but I want:

| abc | xyz | lmn | abk | nkf | etc |
| --- | --- | --- | --- | --- | --- |
| 122 | 233 | 111 | 222 | 111 | 012 |
JustinStolle
  • 4,182
  • 3
  • 37
  • 48
  • Can you specify (and tag) which system you're using? The correct answer could be dependent on that. e.g. [tag:sql-server], [tag:mysql], [tag:postgresql], [tag:ms-access], etc. – JustinStolle Jan 10 '20 at 18:51
  • Also, please include any version-specific tags such as [tag:sql-server-2016] for example. – JustinStolle Jan 10 '20 at 18:57
  • i am using Ms SQL 2012 – Ahsan Ul Haq Jan 10 '20 at 19:34
  • Have you searched for similar questions? For instance, [this answer](https://stackoverflow.com/a/10404455/92389) may apply to your situation. – JustinStolle Jan 10 '20 at 20:05
  • DEAR sir i get the disired resluts but i want to save that result to temp table is it possible we can save selected data to temp table where column are dynamic ?/ – Ahsan Ul Haq Jan 11 '20 at 05:56

0 Answers0