我希望结果行与逗号分隔值在一行中,所以我应用了
rtrim(xmlagg(xmlelement(e, column_name|| ',')).extract('//text()').extract('//text()'),',')
在以下查询的结果行上
SELECT
TO_DATE('01-04-2012','dd-MM-yyyy') - 1 + rownum AS d
FROM all_objects
WHERE TO_DATE('01-04-2012','dd-MM-yyyy') - 1 + rownum
<= TO_DATE('30-04-2012','dd-MM-yyyy')
MINUS
SELECT TS_DATE
FROM TS_DTL where emp_id=3 and TS_DATE BETWEEN TO_DATE('01-04-2012','dd-MM-yyyy')
AND TO_DATE('30-04-2012','dd-MM-yyyy')
当我这样做时:
SELECT
rtrim(xmlagg(xmlelement(e, TO_DATE('01-04-2012','dd-MM-yyyy') - 1 + rownum || ','))
.extract('//text()')
.extract('//text()') ,',') AS d
FROM all_objects
WHERE TO_DATE('01-04-2012','dd-MM-yyyy') - 1 + rownum
<= TO_DATE('30-04-2012','dd-MM-yyyy')
MINUS
SELECT
rtrim(xmlagg(xmlelement(e, TS_DATE || ','))
.extract('//text()')
.extract('//text()') ,',')
FROM TS_DTL
WHERE emp_id=3
AND TS_DATE
BETWEEN TO_DATE('01-04-2012','dd-MM-yyyy')
AND TO_DATE('30-04-2012','dd-MM-yyyy')
它不减去第二个查询结果。