Solved

Oracle SQL statement error

Posted on 2013-11-27
11
346 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
 
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
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 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
 
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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 123
join 2 views with 5 conditions 3 56
dbms_crypto.decrypt   errors out 6 31
create a nested synonym 4 25
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

803 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