SELECT 99-TO_NUMBER(SUBSTR(190002, 2, 2)) FROM DUAL;答案是9!
select a.地区,a.店铺,a.编号 bh,a.规格 gg,a.结存 cun,b.ss_name as pz from 各店上销存 a,主产品编号品种档案 b where a.结存>0 and a.地区||a.店铺='包头王府井' and a.编号=b.s_no and b.ss_name='衬衫' and 99-to_number(substr(a.编号,2,2))=9 order by a.编号
SELECT SUBSTR(a.编号,2,2) ..... 你弄出来看看再说· ··
select a.地区,a.店铺,a.编号 bh,a.规格 gg,a.结存 cun,b.ss_name as pz, substr(a.编号,2,2) from 各店上销存 a,主产品编号品种档案 b where a.结存>0 and a.地区||a.店铺='包头王府井' and a.编号=b.s_no and b.ss_name='衬衫' --and 99-to_number(substr(a.编号,2,2))=9 order by a.编号看看substr(a.编号,2,2)这个的输出值吧,问题还是应该出在这
全部数据里的编号都是这样的吗? 你只列出来了3行数据。用这个查查有没有结果select substr(a.编号,2,2), a.编号 from 各店上销存 a where translate(substr(a.编号,2,2), '0123456789', '0000000000') <> '00';另外,最好别用中文表名和字段名。
select substr(a.编号,2,2),a.* from a where translate(substr(a.编号,2,2),'@0123456789','@') is not null and rownum<=10 ; 用这个语句先查出异常的数据,肯定有substr(a.编号,2,2)不是数字的。
select 30-to_number(substr('12343',2,2)) from dual
结果7
没有问题啊
1* select substr(a.编号,2,2) , a.地区,a.编号 bh,b.ss_name as pz from 各店上销存 a.......
2 ;SUBS 地区
---- --------------------------------------------------
BH PZ
-------------------------------------------------- --------------------
90 包头
29021B10351F3 衬衫90 包头
29021B10351F3 衬衫90 包头sql/plus 里能输出截取的字符串啊
你弄出来看看再说· ··
substr(a.编号,2,2)
from 各店上销存 a,主产品编号品种档案 b
where a.结存>0 and a.地区||a.店铺='包头王府井'
and a.编号=b.s_no and b.ss_name='衬衫'
--and 99-to_number(substr(a.编号,2,2))=9
order by a.编号看看substr(a.编号,2,2)这个的输出值吧,问题还是应该出在这
看看是啥?
--------------------------------------------------
店铺
--------------------------------------------------
BH GG
-------------------------------------------------- -----
CUN PZ SUBS
---------- -------------------- ----
包头
王府井
29021A11111L1 12
1 衬衫 90
你只列出来了3行数据。用这个查查有没有结果select substr(a.编号,2,2), a.编号
from 各店上销存 a
where translate(substr(a.编号,2,2), '0123456789', '0000000000') <> '00';另外,最好别用中文表名和字段名。
to_number(decode(a.编号,null,'0',a.编号)
from a
where translate(substr(a.编号,2,2),'@0123456789','@') is not null
and rownum<=10
;
用这个语句先查出异常的数据,肯定有substr(a.编号,2,2)不是数字的。