郁闷死了。下面这个order by子句,大家帮忙看看怎么写啊。
select sonpuid from prelation where fatherpuid = (SELECT puid FROM pitemrevision where rownum<=1 and itemtag IN ( select itemtag from pitemrevision a,pbomline b WHERE a.puid = B.CHILDITEM ) order by itemrevisionid desc);为什么提示order前面缺少右括号错误。在SQL Server中执行是好的。请问怎么才能实现上面的SQL的功能啊。很急啊。
select sonpuid from prelation where fatherpuid = (SELECT puid FROM pitemrevision where rownum<=1 and itemtag IN ( select itemtag from pitemrevision a,pbomline b WHERE a.puid = B.CHILDITEM ) order by itemrevisionid desc);为什么提示order前面缺少右括号错误。在SQL Server中执行是好的。请问怎么才能实现上面的SQL的功能啊。很急啊。
from prelation
where fatherpuid =
(SELECT puid
FROM pitemrevision
where rownum <= 1
and itemtag IN (select itemtag
from pitemrevision a, pbomline b
WHERE a.puid = B.CHILDITEM)
order by itemrevisionid desc);order by有什么意义?返回结果只有一行!
另外: 8i不支持子查询的order by 语法
你是不是应该把order by itemrevisionid desc里的itemrevisionid 改称puid 阿
from prelation
where fatherpuid =
(
select puid from (
SELECT puid
FROM pitemrevision
where itemtag IN (
select itemtag
from pitemrevision a, pbomline b
WHERE a.puid = B.CHILDITEM
)
order by itemrevisionid desc
)
where rownum <= 1
);
create global temporary table tab_name
SELECT puid
FROM pitemrevision
WHERE ROWNUM <= 1
AND itemtag IN (SELECT itemtag
FROM pitemrevision a, pbomline b
WHERE a.puid = b.childitem)
ORDER BY itemrevisionid DESC
;然后
select sonpuid
from prelation
where fatherpuid in select * from tab_name;这样肯定可以。呵呵
create global temporary table tab_name as