目前的SQL语句是这样的:
select TRIM(item_value) from A
where TRIM(item_name) in (select item_ch from B where configtype='XX')
item_name从select item_ch from B where configtype='xx'中获得。现在的问题是:
我希望select item_ch from B where configtype='xx' 是可以排序的,我这样写,提示错误:
select TRIM(item_value) from A
where TRIM(item_name) in (select item_ch from B where configtype='XX' order by test)请问该怎么写啊?谢谢
select TRIM(item_value) from A
where TRIM(item_name) in (select item_ch from B where configtype='XX')
item_name从select item_ch from B where configtype='xx'中获得。现在的问题是:
我希望select item_ch from B where configtype='xx' 是可以排序的,我这样写,提示错误:
select TRIM(item_value) from A
where TRIM(item_name) in (select item_ch from B where configtype='XX' order by test)请问该怎么写啊?谢谢
where TRIM(item_name) in (select item_ch from B where configtype='XX')
order by TRIM(item_name)
select TRIM(item_value) from A
where TRIM(item_name) in (select item_ch from ( select * from B where configtype='XX' order by test))试试这样写呢?
select TRIM(item_value) from A,B
where TRIM(a.item_name)=b.item_ch and b.configtype='XX'
order by b.test
写后面,好像可以啦!
where exists(select * from B where configtype='XX' and A.item_name=B.item_ch order by TRIM(item_name))--在这里排序么什么作用的,另外建议用exists
where exists(select * from B where configtype='XX' and A.item_name=B.item_ch)
order by test
where TRIM(item_name) in (select top 100 item_ch from B where configtype='XX' order by test) --TOP 100只是估计的数字看你怎么排序了!若要在最后排序的话就 加 order by TRIM(item_value)
oracle中没有top 100的用法