Solved

Oracle SQL statement error

Posted on 2013-11-27
11
349 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pivot rows to columns 1 59
Oracle create type table from existing table%rowtype ? 6 91
Migration from sql server to oracle 5 49
error starting form builder in 11g 2 47
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…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
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.

739 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