将行作为列返回
我很想将其作为单个查询来完成,但我认为它需要一个游标。如果我不能将其作为单个查询来执行,我想将结果作为 SYS_REFCURSOR 输出。简化示例:
PRODUCT
ID NAME Part Number SKU
------------------------------------
1 Widgetizer 150 1001
2 Widgetizer200 200 1002
3 WidgetizerDlx 250 1003
PRODUCT_SPEC
P_ID NAME VALUE
----------------------------
1 WEIGHT 5
1 HEIGHT 10
1 VERSION 1
1 COLOR RED
2 WEIGHT 7
2 HEIGHT 10
2 VERSION 2
2 COLOR BLUE
查询:
对于每个 SKU 小于 1003 的产品,返回:
Product name, part #, SKU, WEIGHT, HEIGHT, COLOR
I'd love to do it as a single query, but I think it's going to require a cursor. If I can't do it as a single query, I'd like to output the results as a SYS_REFCURSOR. A simplified example:
PRODUCT
ID NAME Part Number SKU
------------------------------------
1 Widgetizer 150 1001
2 Widgetizer200 200 1002
3 WidgetizerDlx 250 1003
PRODUCT_SPEC
P_ID NAME VALUE
----------------------------
1 WEIGHT 5
1 HEIGHT 10
1 VERSION 1
1 COLOR RED
2 WEIGHT 7
2 HEIGHT 10
2 VERSION 2
2 COLOR BLUE
Query:
For each product with SKU less than 1003, return:
Product name, part #, SKU, WEIGHT, HEIGHT, COLOR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常称为枢轴查询。
Generally referred to as a pivot query.