how to count group by data on two union table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • achikeziey
    New Member
    • Jun 2012
    • 1

    how to count group by data on two union table

    Code:
    select mobile ,count(id) from
    (select  mobile ,id from phone_1204 where astatus='newsub' and left(service,4)='euro'
    union all
    select mobile,id from phone_1205 where astatus='newsub' and left(service,4)='euro' )
     group by mobile
    are this the right code
    Last edited by Rabbit; Jun 1 '12, 03:07 PM. Reason: Please use code tags when posting code.
  • India777
    New Member
    • Apr 2012
    • 61

    #2
    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:
    Code:
    select @@rowcount as count, mobile ,count(id) from
    (select mobile ,id from phone_1204 where astatus='newsub' and left(service,4)='euro'
    union all
    select mobile,id from phone_1205 where astatus='newsub' and left(service,4)='euro' )
    group by mobile

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Please use code tags when posting code.

      If you run it, you will know if it's correct or not.

      Comment

      Working...