?
Solved

ORACLE SQL:  Add a count to query

Posted on 2010-11-10
2
Medium Priority
?
437 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

650 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