由买买提看人间百态

topics

全部话题 - 话题: houseid
(共0页)
B*****g
发帖数: 34098
1
来自主题: Database版 - 问题:行换列, pivot table
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
发帖数: 1511
2
来自主题: Database版 - 问题:行换列, pivot table
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
(共0页)