Solved

ORACLE SQL:  Error single group function

Posted on 2010-11-18
5
412 Views
Last Modified: 2012-06-27
Experts,

I am using Oracle 10G and I am getting this messagewhen I am run this function.
 Execute:
      [RESULT] = "NOCREPORTS"."TEST_NOC_KEY_INDICATOR_REPORT"

---------------------------------------------------------------------------------------------------

I usually works but I just added values for a column named ENDING_PLAN and the query that is
(SELECT COUNT(*) FROM ARADMIN.PLATFORM_EVENT WHERE UDF_CONVERT_UNIX_DATETIME(DATE_CREATED, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '16' HOUR) AND UDF_CONVERT_UNIX_DATETIME(DATE_CREATED, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '8' HOUR) AND NOC_MANAGED = 0)

I am not sure how I should add this into the function.  Please see below  Thanks



INSERT INTO noc_key_indicator_values (field_id, field_value, report_id, report_date, show_date, KEY_INDICATOR, ENDING_PLAN)
   SELECT   'S8_1', COUNT (npe1.ticket_id), 'SO-DYLY-01', TRUNC (SYSDATE), TO_CHAR (SYSDATE - 1, 'DAY'), '  # BHN Platform Events Triaged & Dispatched <=15 Minutes of Engagement', (SELECT COUNT(*) FROM ARADMIN.PLATFORM_EVENT WHERE UDF_CONVERT_UNIX_DATETIME(DATE_CREATED, 'US/Eastern') >= (TRUNC(SYSDATE) - INTERVAL '24' HOUR) AND UDF_CONVERT_UNIX_DATETIME(DATE_CREATED, 'US/Eastern') < (TRUNC(SYSDATE) - INTERVAL '16' HOUR) AND NOC_MANAGED = 0)
     FROM   (SELECT   *
               FROM   nocreports.tts_tkt_assignment_history
              WHERE   tah_request_id IN
                            (  SELECT   MIN (tah_request_id)
                                 FROM   nocreports.tts_tkt_assignment_history
                                WHERE       tah_assign_start_date >= (TRUNC (SYSDATE) - INTERVAL '24' HOUR)
                                        AND tah_assign_start_date < (TRUNC (SYSDATE) - INTERVAL '16' HOUR)
                                        AND tah_current_combined_group = 'National-Surveillance'
                                        AND tah_form_name = 'Platform Event'
                             GROUP BY   tah_ticket_id)) ia1,
            (SELECT   ticket_id
               FROM   aradmin.platform_event
              WHERE       udf_convert_unix_datetime (date_created, 'US/Eastern') >= (TRUNC (SYSDATE) - INTERVAL '24' HOUR)
                      AND udf_convert_unix_datetime (date_created, 'US/Eastern') < (TRUNC (SYSDATE) - INTERVAL '16' HOUR)
                      AND noc_managed = 0) npe1
    WHERE   npe1.ticket_id = ia1.tah_ticket_id AND tah_assignment_seconds <= 900;

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
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 34166879
you have used an aggregate (COUNT)  but you haven't specified a group by clause

every non-aggregate /non-constant column must be in a group by
0
 

Author Comment

by:Maliki Hassani
ID: 34166929
Sdstuber:  Do you know of a way to rearrange this function so it can work?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 34167007
try this...


INSERT INTO noc_key_indicator_values(field_id,
                                     field_value,
                                     report_id,
                                     report_date,
                                     show_date,
                                     key_indicator,
                                     ending_plan
                                    )
    SELECT 'S8_1',
           cnt,
           'SO-DYLY-01',
           TRUNC(SYSDATE),
           TO_CHAR(SYSDATE - 1, 'DAY'),
           '  # BHN Platform Events Triaged & Dispatched <=15 Minutes of Engagement',
           (SELECT COUNT(*)
              FROM aradmin.platform_event
             WHERE udf_convert_unix_datetime(date_created, 'US/Eastern') >=
                       (TRUNC(SYSDATE) - INTERVAL '24' HOUR)
                   AND udf_convert_unix_datetime(date_created, 'US/Eastern') <
                           (TRUNC(SYSDATE) - INTERVAL '16' HOUR)
                   AND noc_managed = 0)
      FROM (SELECT COUNT(npe1.ticket_id) cnt
              FROM (SELECT *
                      FROM nocreports.tts_tkt_assignment_history
                     WHERE tah_request_id IN
                               (SELECT   MIN(tah_request_id)
                                    FROM nocreports.tts_tkt_assignment_history
                                   WHERE tah_assign_start_date >=
                                             (TRUNC(SYSDATE) - INTERVAL '24' HOUR)
                                         AND tah_assign_start_date <
                                                 (TRUNC(SYSDATE)
                                                  - INTERVAL '16' HOUR)
                                         AND tah_current_combined_group =
                                                 'National-Surveillance'
                                         AND tah_form_name = 'Platform Event'
                                GROUP BY tah_ticket_id)) ia1,
                   (SELECT ticket_id
                      FROM aradmin.platform_event
                     WHERE udf_convert_unix_datetime(date_created,
                                                     'US/Eastern'
                                                    ) >=
                               (TRUNC(SYSDATE) - INTERVAL '24' HOUR)
                           AND udf_convert_unix_datetime(date_created,
                                                         'US/Eastern'
                                                        ) <
                                   (TRUNC(SYSDATE) - INTERVAL '16' HOUR)
                           AND noc_managed = 0) npe1
             WHERE npe1.ticket_id = ia1.tah_ticket_id
                   AND tah_assignment_seconds <= 900);
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 34167012
I moved the aggregate out of the same scope as the subquery
0
 

Author Comment

by:Maliki Hassani
ID: 34167216
Great Stuff..  You are so smart!!
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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 shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

695 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