Solved

Oracle SQL statement error

Posted on 2013-11-27
11
350 Views
Last Modified: 2014-02-19
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
0
Comment
Question by:mikeysmailbox1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 39681103
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
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39681115
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

0
 
LVL 1

Author Comment

by:mikeysmailbox1
ID: 39681150
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
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 74

Expert Comment

by:sdstuber
ID: 39681156
20131010100000001  has 3 too many characters  

2013112423595959  has 2 too many characters
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 39681174
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
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 83 total points
ID: 39681211
neither should have been accepted as both contain errors ... :)

suggest an easier comparison ?

and START_TIME >= to_date('20131010', 'YYYYMMDD')
and END_TIME < to_date('20131125', 'YYYYMMDD')
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 39681220
Since the values are erroneous, we don't know what the values are supposed to be in order to recommend valid logic rearrangement.
0
 
LVL 13

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 84 total points
ID: 39681936
I don't understand why the question was closed as it was.

Apart from that, if accepting & closing this answer like this, a split would have been more than fair as sdstuber replied 3 minutes before!!
If you do not want to split, then please give him the entire points...
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39682860
sdstuber,
you could at least gave given your best "scientific wild ass guess", no ?
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 83 total points
ID: 39683270
sure, in that case I think I'd change the bottom range, because I'm assuming the ending "01" is supposed to be there and the thought is to exclude the second of midnight

and START_TIME > to_date('20131010', 'YYYYMMDD')
and END_TIME < to_date('20131125', 'YYYYMMDD')

so, I think that's the most likely translation of what the syntax was "intended" to be;
but it seems kind of odd to me and not likely what it "should" have been

either way, doesn't resolve what seems to be an inappropriate close
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question