Concatenate results from a SQL query in Oracle(在 Oracle 中连接 SQL 查询的结果)
问题描述
我在表格中有这样的数据
I have data like this in a table
NAME PRICE
A 2
B 3
C 5
D 9
E 5
我想在一行中显示所有值;例如:
I want to display all the values in one row; for instance:
A,2|B,3|C,5|D,9|E,5|
在 Oracle 中,我将如何进行查询以提供这样的字符串?我不需要它被编程成什么东西;我只是想要一种方法让该行出现在结果中,以便我可以将其复制并粘贴到 Word 文档中.
How would I go about making a query that will give me a string like this in Oracle? I don't need it to be programmed into something; I just want a way to get that line to appear in the results so I can copy it over and paste it in a word document.
我的 Oracle 版本是 10.2.0.5.
My Oracle version is 10.2.0.5.
推荐答案
-- Oracle 10g --
-- Oracle 10g --
SELECT deptno, WM_CONCAT(ename) AS employees
FROM scott.emp
GROUP BY deptno;
Output:
10 CLARK,MILLER,KING
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD
这篇关于在 Oracle 中连接 SQL 查询的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Oracle 中连接 SQL 查询的结果


基础教程推荐
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01