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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:10:12+00:00 2026-05-31T17:10:12+00:00

I have the following Mock table: +———+——————-+——+——+ | NAME | TITLE | SIZE |

  • 0

I have the following Mock table:

+---------+-------------------+------+------+
| NAME    | TITLE             | SIZE |  Hit |
+---------+-------------------+------+------+
| A       | Hippo1            | H    |  0   |
| A       | Hippo2            | H    |  0   |
| A       | Hippo3            | H    |  1   |   
| A       | Hippo1            | M    |  0   |
| A       | Hippo2            | M    |  1   |
| A       | Hippo3            | M    |  1   |
| A       | Hippo1            | L    |  0   |
| A       | Hippo2            | L    |  1   |    
| A       | Hippo3            | L    |  1   |
+---------+-------------------+------+------+
| B       | Snail1            | H    |  1   |
| B       | Snail1            | M    |  0   |
| B       | Snail1            | L    |  1   |
+---------+-------------------+------+------+
| C       | Dog               | H    |  1   |
| C       | Dog               | M    |  0   |
+---------+-------------------+------+------+
| D       | Sheep             | H    |  0   |
| D       | Sheep             | L    |  1   |
+---------+-------------------+------+------+
| E       | Fish              | H    |  1   |
| E       | Fish              | H    |  1   |
+---------+-------------------+------+------+

My Desired Result would

+---------+----------+-------+
| NAME    | TITLE    | SCORE |
+---------+----------+-------+
| A       | Hippo    |  100  |
| B       | Snail    |   80  |
| C       | Dog      |   80  |
| D       | Sheep    |   10  |
| E       | Fish     |  100  |
+---------+----------+-------+

Computations required:

  • Type can have only three values at most: {H, M, L};
  • When all values are present, they are graded as followed: H=70 M=20 L=10
  • ALL unique casese are

    1. Case {H,M} : H=80 M=20
    2. Case {M,L} : M=60 L=40
    3. Case {H,L} : H=90 L=10
    4. Case {H} : H=100
    5. Case {M} : M=100
    6. Case {L} : L=100
    7. Case {H,M,L} : H=70 M=20 L=10

Explanation:

Hippo Has case {H,M,L}
Snail has case {H,M,L}
Dog has case {H,M}
Sheep has case {H,L}
Fish has case {H} 

Further Explanation

Hippo : Athough not all sizes have a hit, Hippo has gained the score 100 because atleast 1 of each case has been satified once per title. Hence HIPPO3 has all three H M
L satsified so hippo can be conidered found 100 percent

Extracted from above (lines are logical construct for viewer)

| A       | Hippo1            | H    |  0   |
| A       | Hippo2            | H    |  0   |
| A       | Hippo3            | H    |  1   | <--Here   
+-------------------------------------------+    
| A       | Hippo1            | M    |  0   |
| A       | Hippo2            | M    |  1   |
| A       | Hippo3            | M    |  1   | <--Here
+-------------------------------------------+   
| A       | Hippo1            | L    |  0   |
| A       | Hippo2            | L    |  1   |    
| A       | Hippo3            | L    |  1   | <--Here
  • 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-31T17:10:13+00:00Added an answer on May 31, 2026 at 5:10 pm

    Here you go:

    select name, sum(FinalVal) Score from (
      select distinct t.name,
        case
          when size = 'H' then Hval
          when size = 'M' then Mval
          else Lval
        end FinalVal
      from (
        select name,
          case
            when sizes = 'H,L,M' then 70
            when sizes = 'H,M' then 80
            when sizes = 'H,L' then 90
            when sizes = 'H' then 100
            else 0
          end Hval,
          case
            when sizes = 'H,L,M' then 20
            when sizes = 'H,M' then 20
            when sizes = 'L,M' then 60
            when sizes = 'M' then 100
            else 0
          end Mval,
          case
            when sizes = 'H,L,M' then 10
            when sizes = 'L,M' then 40
            when sizes = 'H,L' then 10
            when sizes = 'L' then 100
            else 0
          end Lval
        from (
          select name, group_concat(distinct size order by size) sizes from t
          group by name
        ) s1
      ) s2
      join t on t.name = s2.name
      where hit
    ) final
    group by name
    

    It is not clear how to get the Title given your data (actually the result has data it is not present in the original tables, such as Hippo, instead of Hippo1. But I’ll leave that to you.

    This will result in:

    +------+-------+
    | NAME | SCORE |
    +------+-------+
    | A    |   100 |
    | B    |    80 |
    | C    |    80 |
    | D    |    10 |
    | E    |   100 |
    +------+-------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to mock java.awt.Toolkit.beep() using JMockit Expectations. I have the following code
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following situation. A main table and many other tables linked together with
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have the following Logger I want to mock out, but to validate log
This is a scjp mock exam question. Suppose I have the following two files:
If I have the following class, how do I use RhinoMocks to mock the
I have the following code: var service = new Mock<INavigationService>(); service.Setup(x => x.GetSchemes(new SchemeFilterEntity())).Returns(new
I have the following methods.. I'd like to be able to mock something up
Say I have a following class: case class Mock(id: Int, pty1: String, pty2: String)

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.