?
Solved

Oracle SQL statement error

Posted on 2013-11-27
11
Medium Priority
?
351 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 332 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 336 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 38

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 332 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

764 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