• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Please modify my exisitng query

I have a simple table tblMain
Title                       Count
Status One           2
Status Two          3
Status Three          1
so to get the select statement :)   you go
select * from tblMain

i want to modify the query and include the grandtotal also , so the results should be :

Title                       Count
Status One           2
Status Two          3
Status Three         1
Total                     6

it is simple to use two queries and then combine using union query
I need it as one query
0
rfedorov
Asked:
rfedorov
1 Solution
 
omgangCommented:
Select Title, [Status One], [Status Two], [Status Three], ([Status One] + [Status Two] + [Status Three]) As Total FROM tblMain

Is this what you want?
OM Gang
0
 
rfedorovAuthor Commented:
i did not get,  no, i do not want that
what if i have fifty different statuses, ?
0
 
Rey Obrero (Capricorn1)Commented:
try this

select title,[count] from tblMain
union
select 'Total' as title, sum([count]) from tblMain
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rfedorovAuthor Commented:
That is what i was thinking, you use two queries and union them, I did that...
It is working...
is there just one select query?
0
 
GRayLCommented:
You cannot get there from here.  - ie.  without using a union query ;-)
0
 
Rey Obrero (Capricorn1)Commented:
<is there just one select query?> no, can't be done
you have to do a union
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now