468,768 Members | 1,452 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

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 1863
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,515 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

1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.