n********6 发帖数: 1511 | 1 Background:
Collected phone number from 10 sources for each household. Past validation
indicates phone number may have one of 20 status (1, valid, 2, fax, 3, busy,
4, person died, 5, ill, 6, in jail, ... 20)
Question:
Any way to do one query without using cursor go through whole table? (no
concern on performance issue)
Old Table:
HouseID (PK)
APhoneNumber
AStatus
BPhoneNumber
BStatus
...
GPhoneNumber
GStatus | B*****g 发帖数: 34098 | 2 SELECT HouseID, APhoneNumber, AStatus, 'A' PhoneColumns
UNION ALL
SELECT HouseID, BPhoneNumber, BStatus, 'B'
UNION ALL
....
PhoneColumns may be used for remove duplicate
busy,
【在 n********6 的大作中提到】 : Background: : Collected phone number from 10 sources for each household. Past validation : indicates phone number may have one of 20 status (1, valid, 2, fax, 3, busy, : 4, person died, 5, ill, 6, in jail, ... 20) : Question: : Any way to do one query without using cursor go through whole table? (no : concern on performance issue) : Old Table: : HouseID (PK) : APhoneNumber
| n********6 发帖数: 1511 | 3 Thank you very much.
Yeah! Union All!
Simple is beautiful.
【在 B*****g 的大作中提到】 : SELECT HouseID, APhoneNumber, AStatus, 'A' PhoneColumns : UNION ALL : SELECT HouseID, BPhoneNumber, BStatus, 'B' : UNION ALL : .... : PhoneColumns may be used for remove duplicate : : busy,
|
|