0

我有 EMP 表它的列按照 Oracle 中的 Scott。我想在一个名为“语句”的列中显示所有列,如下所示。

前福特是一名分析师,他的经理是琼斯,部门研究部门的薪水为 3000

金是总统,他的经理没有部门会计的薪水 5000

4

3 回答 3

2

尝试这样的事情:

SELECT emp.ename || ' IS A ' || emp.job || ' AND HIS MANAGER IS ' || mgr.ename || ' HAVING SALARY ' || TO_CHAR(emp.sal) || ' FROM DEPARTMENT ' || dept.dname
FROM emp
INNER JOIN emp AS mgr ON emp.mgr = mgr.empno
INNER JOIN dept ON dept.deptno = emp.deptno
于 2013-08-14T13:14:31.443 回答
1

您可以使用管道组合字符串:

SELECT 'COLUMN1' || ' ' || 'COLUMN2'
FROM DUAL

编辑:

使用可空管理器的实际查询进行更新:

 SELECT emp.ename || ' IS A ' || emp.job || ' AND HIS MANAGER IS ' || NVL(mgr.ename, 'NULL') || ' HAVING SALARY ' || TO_CHAR(emp.sal) || ' FROM DEPARTMENT ' || dept.dname
 FROM emp
 LEFT JOIN emp AS mgr ON emp.mgr = mgr.empno
 INNER JOIN dept ON dept.deptno = emp.deptno
于 2013-08-14T13:12:11.317 回答
0
select x.ENAME||' is a ' || x.JOB||' and his manager is '||y.ENAME||' having salary '||x.sal||' from department '||d.DNAME
FROM EMP x, EMP y, dept d
where x.MGR = y.EMPNO(+)
and x.DEPTNO = d.DEPTNO
于 2013-08-14T13:16:28.347 回答