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
Solved

ORACLE SQL:  Add a count to query

Posted on 2010-11-10
2
429 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
2 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 500 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

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

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

839 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