这是我在做数据库查询时候的SQL语句。
select tb.sitemcd,i.item,tb.qt from (select distinct(b.sitemcd),decode(b.sitemcd,a.sitemcd,(b.qt-a.qt),b.qt) qt from (select sitemcd,sum(qt) qt from item_bom where mitemcd= 'E27EI8000000BM03' and factcd='00062' group by sitemcd) a, (select sitemcd,sum(qt) qt from item_bom where mitemcd='E272EA000000BM03' and factcd='00062' group by sitemcd) b where (b.sitemcd=a.sitemcd and b.qt>a.qt) or b.sitemcd not in (select distinct(sitemcd) from item_bom where mitemcd='E27EI8000000BM03' and factcd='00062' )) tb,item i where tb.sitemcd=i.itemcd(+) order by tb.sitemcd运行程序:
Statement stmt = null;
stmt = this.conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);但是System.out.println(rs.next());显示的是false.
我把SQL占到sql plus中可以找到数据!什么原因呢?
select tb.sitemcd,i.item,tb.qt from (select distinct(b.sitemcd),decode(b.sitemcd,a.sitemcd,(b.qt-a.qt),b.qt) qt from (select sitemcd,sum(qt) qt from item_bom where mitemcd= 'E27EI8000000BM03' and factcd='00062' group by sitemcd) a, (select sitemcd,sum(qt) qt from item_bom where mitemcd='E272EA000000BM03' and factcd='00062' group by sitemcd) b where (b.sitemcd=a.sitemcd and b.qt>a.qt) or b.sitemcd not in (select distinct(sitemcd) from item_bom where mitemcd='E27EI8000000BM03' and factcd='00062' )) tb,item i where tb.sitemcd=i.itemcd(+) order by tb.sitemcd运行程序:
Statement stmt = null;
stmt = this.conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);但是System.out.println(rs.next());显示的是false.
我把SQL占到sql plus中可以找到数据!什么原因呢?
是SQL语句太长了吗?
我也有同感。
建议楼主把你的SQL语句优化
结贴!
谢谢大家批评我的SQL语句不好看!哈哈!