目前的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)请问该怎么写啊?谢谢

解决方案 »

  1.   

    select TRIM(item_value) from A
    where TRIM(item_name) in (select item_ch from B where configtype='XX')
    order by TRIM(item_name)
      

  2.   


    select TRIM(item_value) from A
    where TRIM(item_name) in (select item_ch from ( select * from B where configtype='XX' order by test))试试这样写呢?
      

  3.   

    --这样 
    select TRIM(item_value) from A,B
    where TRIM(a.item_name)=b.item_ch and b.configtype='XX'
    order by b.test
      

  4.   

    order by TRIM(item_name) 
    写后面,好像可以啦!
      

  5.   

    select TRIM(item_value) from A
    where exists(select * from B where configtype='XX' and A.item_name=B.item_ch order by TRIM(item_name))--在这里排序么什么作用的,另外建议用exists
      

  6.   

    select TRIM(item_value) from A
    where exists(select * from B where configtype='XX' and A.item_name=B.item_ch)
    order by test
      

  7.   

    若要在子查询中使用ORDER BY 可以这样做。select TRIM(item_value) from A
    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)
      

  8.   


    oracle中没有top 100的用法