We help IT Professionals succeed at work.

RE: ORA-01722:invalid number

iamjhkang
iamjhkang asked
on
1,768 Views
Last Modified: 2007-12-19
I have a query which collects the traffic of recent 3 weeks.
To my disappointment, I got a "ORA-01722:invalid number" error message.

One thing strange is when I omit the condition "( wtd_avg_3weeks.week_no = 1)" it works ok like;

CPR_AGR,TRAFFIC,WEEK_NO
0.486553940225869,23394,3
0.465235748008569,22369,2
0.415735945591814,19989,1

I use Oracle 8.1.7.
How can I solve this problem?

TIA.

The query is as follows.

SELECT wtd_avg_3weeks.cpr_agr, wtd_avg_3weeks.traffic,wtd_avg_3weeks.week_no
FROM (select weighted_avg_traffic.eis_date,
             decode(to_char(to_date(weighted_avg_traffic.eis_date,'yyyymmdd'),'d'),'1','SUN','2','MON','3','TUE','4','WED','5','THU','6','FRI','7','SAT') as weekday,
             decode(to_number(to_char(to_date(weighted_avg_traffic.eis_date,'yyyymmdd')-to_date(a.eis_date,'yyyymmdd'),'99'))/7,0,3,1,2,2,1) as week_no,
             weighted_avg_traffic.traffic,48081 as agree,
             (weighted_avg_traffic.traffic/48081) as cpr_agr
        from weighted_avg_traffic,
            (select eis_date
               from weighted_avg_traffic
              where eis_date between to_char(sysdate-21,'yyyymmdd') and to_char(sysdate-15,'yyyymmdd')
                and to_char(to_date(eis_date,'yyyymmdd'),'d')='2') a    
       where weighted_avg_traffic.eis_date between a.eis_date and to_char(sysdate-1,'yyyymmdd')
       order by 1) wtd_avg_3weeks
WHERE ( wtd_avg_3weeks.weekday='MON' ) and  ( wtd_avg_3weeks.week_no = 1)

Comment
Watch Question

What's the datatype of the wtd_avg_3weeks.week_no column?  If it is varchar2 then ensure that you have no non-numeric data in there (i.e. a space).  If you want a quick test to see if that could be the problem, try:
wtd_avg_3weeks.week_no = '1'
Instead of
wtd_avg_3weeks.week_no = 1

Author

Commented:
Same result
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Or, change the format mask to '999'

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.