471,061 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,061 software developers and data experts.

how to count group by data on two union table

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
2 1909
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
12,516 Expert Mod 8TB
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.

Similar topics

reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.