By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,314 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,314 IT Pros & Developers. It's quick & easy.

how to count group by data on two union table

P: 1
Expand|Select|Wrap|Line Numbers
  1. select mobile ,count(id) from
  2. (select  mobile ,id from phone_1204 where astatus='newsub' and left(service,4)='euro'
  3. union all
  4. select mobile,id from phone_1205 where astatus='newsub' and left(service,4)='euro' )
  5.  group by mobile
are this the right code
Jun 1 '12 #1
Share this Question
Share on Google+
2 Replies


India777
P: 61
Try with @@ROWCOUNT.This Returns the number of Rows affected by the Sql Query.Please Study this link to know abount @@ROWCOUNT.
http://technet.microsoft.com/en-us/l.../ms187316.aspx and http://msdn.microsoft.com/en-us/library/ms188774.aspx.

Example:
Expand|Select|Wrap|Line Numbers
  1. select @@rowcount as count, mobile ,count(id) from
  2. (select mobile ,id from phone_1204 where astatus='newsub' and left(service,4)='euro'
  3. union all
  4. select mobile,id from phone_1205 where astatus='newsub' and left(service,4)='euro' )
  5. group by mobile
  6.  
Jun 1 '12 #2

Rabbit
Expert Mod 10K+
P: 12,366
Please use code tags when posting code.

If you run it, you will know if it's correct or not.
Jun 1 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.