Solved

Oracle SQL statement error

Posted on 2013-11-27
11
342 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
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 73

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
 

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
 
LVL 73

Expert Comment

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

2013112423595959  has 2 too many characters
0
 
LVL 73

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 73

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 73

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now