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 |
cable_si
Starting Member
20 Posts |
Posted - 2010-09-19 : 10:48:27
|
HiI am trying to write a query to count all the telephone numbers with a tableThe below would return 6Id Tel1 Tel2 Tel31 01214478953 0797339399332 01212339494 049458585858 012384349343 01232345489Can any one help at allthanksSimon |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-19 : 11:30:20
|
[code]SELECT COUNT(Tel1) + COUNT(Tel2) + COUNT(Tel3)FROM table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2010-09-20 : 04:14:31
|
DECLARE @t1 TABLE(Id INT IDENTITY(1,1) NOT NULL, Tel1 bigint, Tel2 bigint, Tel3 bigint)insert into @t1(Tel1, Tel2, Tel3)values(01214478953,079733939933,null),(01212339494,049458585858,01238434934),(01232345489,null,null)select * from @t1select COUNT(1)from(select TelColumn,TelNofrom@t1unpivot(TelNo for TelColumn in ([Tel1],[Tel2],[Tel3])) t)t1Iam a slow walker but i never walk back |
 |
|
|
|
|
|
|