Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

How can I add a column to a MS SQL view that returns a count of results?

$
0
0

I need to modify a SQL view to output 3 columns each containing a count of results in another column.

The view returns multiple rows each row containing a Status column. I need multiple new output columns, each containing a count of the total of each type of result.

e.g.

Original output column is 'Status' which can resolve as 'Pending', 'Dead' or 'Active'

I need, in this example three new columns headed 'Pending Count', 'Dead Count', 'Active Count', each column containing a single numeric count of the total number of each Status category - if ten rows are Status='Dead' then 'Dead Count' returns '10'

How please?


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>