Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 493975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:27:18+00:00 2026-05-13T05:27:18+00:00

I am writing a custom report from an Avamar (Postgresql) database which contains backup

  • 0

I am writing a custom report from an Avamar (Postgresql) database which contains backup job history. My task is to display jobs that failed last night (based on status_code), and include that client’s success ratio (jobs succeeded/total jobs run) over the past 30 days on the same line.

So the overall select just picks up clients that failed (status_code doesn’t equal 30000, which is the success code). However, for each failed client from last night, I need to also know how many jobs have succeeded, and how many jobs total were started/scheduled in the past 30 days. (The time period part is simple, so I haven’t included it in the code below, to keep it simple.)

I tried to do this without using a nested query, based on Hobodave’s feedback on this similar question but I’m not quite able to nail it.

In the query below, I get the following error:
column "v_activities_2.client_name" must appear in the GROUP BY clause or be used in an aggregate function

Here’s my (broken) query. I know the logic is flawed, but I’m coming up empty with how best to accomplish this. Thanks in advance for any guidance!

select
  split_part(client_name,'.',1) as client_name,
  bunchofothercolumnns,
  round(
    100.0 * (
      ((sum(CASE WHEN status_code=30000 THEN 1 ELSE 0 END))) /
      ((sum(CASE WHEN type='Scheduled Backup' THEN 1 ELSE 0 END))))
    as percent_total
from v_activities_2
  where
    status_code<>30000
  order by client_name
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:27:18+00:00Added an answer on May 13, 2026 at 5:27 am

    You need to define a GROUP BY if you have columns in the SELECT that do not have aggregate functions performed on them:

      SELECT SPLIT_PART(t.client_name, '.', 1) AS client_name,
             SUM(CASE WHEN status_code = 30000 THEN 1 ELSE 0 END) as successes
        FROM v_activities_2
    GROUP BY SPLIT_PART(t.client_name, '.', 1)
    ORDER BY client_name
    

    How do you expect the following to work:

          SUM(CASE WHEN status_code = 30000 THEN 1 ELSE 0 END) as successes
     FROM v_activities_2
    WHERE status_code <> 30000
    

    You can’t expect to count rows you’re excluding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 352k
  • Answers 352k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The most obvious ones are: // will retrieve any param… May 14, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer NLTK and Wordnet can help: e.g., per this article, from… May 14, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer Did you try something like this? select sum(val) from (… May 14, 2026 at 7:28 am

Related Questions

I have an instance of SQL Server 2008 and SSRS 2008 running on a
At the company I work for, I have created a Error Logging class to
I am running a query against a providex database that we use in MAS
I am writing a script that will look in a custom reports directory, copy

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.