?
Solved

ORACLE SQL:  Add a count to query

Posted on 2010-11-10
2
Medium Priority
?
434 Views
Last Modified: 2012-05-10
Experts,

Can someone please help me out with my SQL statement?  My SQL output is showing 4 different ticket ID's but I want it to use the count feature.  Should show just the number 4.

Thanks!!

Using Oracle 10g
(SELECT DISTINCT (RELATED_TICKET_ID)
FROM ARADMIN.EMAIL_REPORTING 
WHERE UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '1' DAY) 
    AND UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY) 
    AND MESSAGE_TYPE = 1 
    AND OWNER_GROUP = 'National-Carrier Operations'
    AND RELATED_TICKET_ID LIKE 'MNT%'
OR UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '1' DAY) 
    AND UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY) 
    AND MESSAGE_TYPE = 0 
    AND OWNER_GROUP = 'National-Carrier Operations'
AND RELATED_TICKET_ID LIKE 'MNT%' 
    AND MAILBOX_NAME IS NOT NULL)

Open in new window

0
Comment
Question by:Maliki Hassani
[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
2 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 2000 total points
ID: 34107004
(SELECT COUNT(DISTINCT (RELATED_TICKET_ID))
FROM ARADMIN.EMAIL_REPORTING
WHERE UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '1' DAY)
    AND UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
    AND MESSAGE_TYPE = 1
    AND OWNER_GROUP = 'National-Carrier Operations'
    AND RELATED_TICKET_ID LIKE 'MNT%'
OR UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '1' DAY)
    AND UDF_CONVERT_UNIX_DATETIME(CREATE_DATE, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '0' DAY)
    AND MESSAGE_TYPE = 0
    AND OWNER_GROUP = 'National-Carrier Operations'
AND RELATED_TICKET_ID LIKE 'MNT%'
    AND MAILBOX_NAME IS NOT NULL)
0
 

Author Closing Comment

by:Maliki Hassani
ID: 34107017
Sweeet,  Thanks
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

752 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