473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 2105
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

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

Similar topics

4
by: Igor | last post by:
I have one SELECT statement that needs to return one ntext field from one table and count something from other table, problem is that all fileds that are not in count have to be in group by and...
2
by: gaston | last post by:
Hi All I have three data bases with a table each one, what I want to do is to get the data from each table and insert it in a new data base table. The thing is that may be there is going to a...
7
by: hjohnson | last post by:
Within the access environment, I have a table that I'd like to -add a column -place the record number of each record into that column The autonumber is not working for me because I am...
5
by: HowHow | last post by:
First time using crosstab query because tired of creating queries and put them together in one query (such a stupid thing to do :D). Not sure how it works still. I have link table called...
1
by: rahullko05 | last post by:
Hi, i am building a small forum site as my final year project & stuck in a very trivial problem. I have a table which are varchar type of data & i am trying to fetch data from table based on...
2
by: shimul | last post by:
Hi, Have table with data ( like a,b,c,d in column 1), want to read data from table and put in text box in continuous form. like tble name "tbltest" and textbox name "txtbox". now want to...
4
Fary4u
by: Fary4u | last post by:
Hi how to count the data ( not count the record )from the table & with the following id ? i'm using asp classic with ado MS Access database with simple query "select * from order where...
3
by: bluethunder | last post by:
Good day everyone, I'm having a hard time with my program on how to display the data from table to combo box. I have two tables that have been LEFT JOIN to have their relationship in the Data...
0
by: naveendb2dba | last post by:
while loading the PK COLUMN data into table I am getting the duplicate key in a table because of PK COLUMN having auto increment. My requirement is what ever data having the ORIGINAL TABLE that...
0
by: rahul more | last post by:
My aim is - Access data from table and show it into a form's textboxes , comboxes for edition of data. I am using listview. I am selecting particular row of listview by clicking on that row and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.