Avatar of mikeysmailbox1
mikeysmailbox1
 asked on

Oracle SQL statement error

Hi

I have the following an its not working and not sure why.

select data_center, group_name, count(*)
  from ( select data_center, group_name from runinfo_history
         where data_center = 'DEV'
            and (ended_status = '16' or ended_status = '32')
            and START_TIME >= to_date('20131010100000001','YYYYMMDDHH24MISS')
            and END_TIME <= to_date('2013112423595959','YYYYMMDDHH24MISS')
        ) as list
group by data_center, group_name;


It comes back "not properly ended"


Thanks for the help.

Mike
Oracle Database

Avatar of undefined
Last Comment
Sean Stuber

8/22/2022 - Mon
Sean Stuber

SELECT data_center, group_name, COUNT(*)
    FROM (SELECT data_center, group_name
            FROM runinfo_history
           WHERE data_center = 'SONY_DEV'
             AND (ended_status = '16' OR ended_status = '32')
             AND start_time >= TO_DATE('20131010100000001', 'YYYYMMDDHH24MISS')
             AND end_time <= TO_DATE('2013112423595959', 'YYYYMMDDHH24MISS')) list
GROUP BY data_center, group_name;


remove the "as" from the inline view alias
Alex [***Alex140181***]

try
select data_center,
       group_name,
       count(*)
  from (select data_center,
               group_name
          from runinfo_history
         where data_center = 'DEV'
           and (ended_status = '16' or ended_status = '32')
           and START_TIME >= to_date('20131010100000001', 'YYYYMMDDHH24MISS')
           and END_TIME <= to_date('2013112423595959', 'YYYYMMDDHH24MISS')) list
 group by data_center,
          group_name;

Open in new window

mikeysmailbox1

ASKER
That fixed the issue with the "as" but now I am getting

ORA-01830: date format picture ends before converting entire input string
01830. 00000 -  "date format picture ends before converting entire input string"

Do I have the date "to_date" wrong?

Thanks

Mike
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Sean Stuber

20131010100000001  has 3 too many characters  

2013112423595959  has 2 too many characters
Sean Stuber

I don't understand why the question was closed as it was.

the accepted answer is a duplicate of what was already posted, and the second half of your syntax error wasn't even addressed in that post
SOLUTION
Geert G

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sean Stuber

Since the values are erroneous, we don't know what the values are supposed to be in order to recommend valid logic rearrangement.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Alex [***Alex140181***]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Geert G

sdstuber,
you could at least gave given your best "scientific wild ass guess", no ?
SOLUTION
Sean Stuber

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.