由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 问题:行换列, pivot table
相关主题
如何寫此 SQL 查詢?请问SQL高手
怎么写个query 把输出变成横排.What's a cursor?
open cursor for collection?Re: 求救!!! 一个oracle的问题! 在procedure中所涉及的表名可以用变量从参数中传入吗
面试问题,关于oracle 8i[转载] Hehe,不好意思,another question:)
老印给我的一个ChallengeHow to store data locally?
better solution for cross table query in sql?ora-00600:internal error
cursor可以往回找否??can I create a recordset with cursor?
问个数据库问题Re: why?ORACLE的c编程中,循环语句中如果出现数据库语句,循环就会死掉
相关话题的讨论汇总
话题: table话题: houseid话题: union话题: bstatus话题: astatus
进入Database版参与讨论
1 (共1页)
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,

1 (共1页)
进入Database版参与讨论
相关主题
Re: why?ORACLE的c编程中,循环语句中如果出现数据库语句,循环就会死掉老印给我的一个Challenge
纪录查找问题better solution for cross table query in sql?
PL/SQL cursor abstract type usage?cursor可以往回找否??
ask for help with a simple query!!!问个数据库问题
如何寫此 SQL 查詢?请问SQL高手
怎么写个query 把输出变成横排.What's a cursor?
open cursor for collection?Re: 求救!!! 一个oracle的问题! 在procedure中所涉及的表名可以用变量从参数中传入吗
面试问题,关于oracle 8i[转载] Hehe,不好意思,another question:)
相关话题的讨论汇总
话题: table话题: houseid话题: union话题: bstatus话题: astatus