-
Hi
We have a table of customers, there are two columns with telephone_1 and telephone_2, normally telephone_2 are used for mobile phone numbers but sometimes telephone_1 is also a mobile, and sometimes the customer has same mobile number for telephone_1 and 2
We have to find out how many customers has mobile phone. How do we do this acurately?
I have tried
select tel_1, tel_2 from customer
where tel_1 like '6%'
or tel_2 like '6%'
group by tel_1, tel_2
which gave me 48 rows back
then
select distinct tel_1 from customer
where tel_1 like '6%'
which gave me back 5 rows
select distinct tel_2 from customer
where tel_1 like '6%'
returns 40 rows
which result is correct???
-
1st query returns one row for each unique pair of tel1 and tel2 when both start with 6.
2nd query returns one row (of tel1) for each unique tel1 which begins with 6.
3rd query returns one row (of tel2) for each tel2 number where tel1 starts with6.
couldn't you just say:
select count(*) from customers where tel1 like '6%' or tel2 like '6%';
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|