Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 08:16:53
|
| hi all, i have a customers table storing tel,mobile,worktel numbers.now i need a query which pull up customers that do not have a minimum of 2 phone numbers..these 3 column can get null values too.pls help |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-10 : 08:24:42
|
| [code]select customer from(select *, case when tel<>'' then 1 else 0 end+case when mobile<>'' then 1 else 0 end+case when worktel<>'' then 1 else 0 end as countingfrom table) as twhere counting<2[/code]MadhivananFailing to plan is Planning to fail |
 |
|
|
malaytech2008
Yak Posting Veteran
95 Posts |
Posted - 2008-11-10 : 08:29:10
|
| How do u storing phone numbers,if it is different table having phone number onlythen I think it work..select p.cust_id from phone p inner join customer c on c.cid=p.cid group by cust_id having count(cust_id)>=2malay |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-10 : 09:08:38
|
| thanks madhivanan |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-10 : 09:20:41
|
quote: Originally posted by soorajtnpki thanks madhivanan
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|