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 6318659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:39:55+00:00 2026-05-24T15:39:55+00:00

During a join I get the following Table (example): +———-+———-+ | Hostname | Severity

  • 0

During a join I get the following Table (example):

+----------+----------+
| Hostname | Severity |
+----------+----------+
| host1    |   high   |
| host2    |  medium  |
| host1    |   high   |
| host2    |   low    |
| host1    |   low    |
| host2    |   low    |
| host1    |   low    |
| host2    |   high   |
| host1    |   high   |
| host2    |   high   |
+----------+----------+

Is it possible to create I JPQL query where I get the following result:

+----------+------+--------+-----+
| Hostname | high | medium | low |
+----------+------+--------+-----+
| host1    |  3   |   0    |  2  |
| host2    |  2   |   1    |  2  |
+----------+------+--------+-----+

I tried with COUNT and GROUP BY but I got something like that:

host1,high,3
host1,medium,0
host1,low,2

etc…

BR, Rene

  • 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-24T15:39:56+00:00Added an answer on May 24, 2026 at 3:39 pm

    A standard sql query would look like this – I’m not sure what effort is required to the API you are using, but its a pretty straight-forward group by with case logic.

    select hostname, 
      sum(case when severity = 'high' then 1 else 0 end) as high,
      sum(case when severity = 'medium' then 1 else 0 end) as medium,
      sum(case when severity = 'low' then 1 else 0 end) as low
    from
      Table
    group by
      hostname
    order by
      hostname
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the installation of Apache2 I got the following message into cmd window: Installing
I am trying to join a number of binary files that were split during
Given the following table structure, how can I use a Linq query to return
Imagine a table with the following structure on PostgreSQL 9.0: create table raw_fact_table (text
I want to left join two tables. My problem is that the table from
How can options/arguments determine which function is chosen during program execution? For the example
during build with Visual Studio C++ I get this error: error C2027: use of
I have two tables that get joined regularly. Table One is about 1 Million
During a discussion about security, a developer on my team asked if there was
During a typical day programming, I implement functions in a way that I would

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.