Sayed Rizwan Hashmi Sayed Rizwan Hashmi - 2 months ago 6x
SQL Question

How to Dispaly Total Count Result in new Column

i am trying to calculate status from one table and total status count but it is display in same column the query is

select Status ,count(Status) from assigntask group by status union all
SELECT count(Status) , count(Status) as total from assigntask ;

And Reslut Show Like This

Status Count
Complete 1
Delay 2
3 3

can it possible no of count "3" will show in another column?

For Example

Status Count Total
Complete 1 3
Delay 2


You have to provide a dummy field in both selects for the union to match up.

SELECT Status, COUNT(Status) as count, NULL as total FROM assigntask GROUP BY status 
SELECT NULL, COUNT(Status), COUNT(Status) FROM assigntask;