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

  • Home
  • SEARCH
  • 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 3425242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:34:14+00:00 2026-05-18T06:34:14+00:00

As an addon to the question I asked a few days ago here at

  • 0

As an addon to the question I asked a few days ago here at sql-query-comparing-two-items-on-distinct-item would it be possible to remove the possibillty of null values where one of the ‘pers’ does not occur in the ‘evt’.

Output

**EVT   John    Paul    Difference**
A1      1       2       -1
A2      2       3       -1
A3      2       NULL    [errors here] - ** item to be removed **

Data

**EVT   PERS    RANK**
A1      John    1
A1      Paul    2
A1      Ringo   3
A1      George  4
A2      Ringo   1
A2      John    2
A2      Paul    3
A2      George  4
A3      Ringo   1
A3      John    2
A3      George  4

Current Code (thanks to Martin Smith)

SELECT 
      EVT,
      MAX(CASE WHEN Pers='John' THEN Rank END) AS John,
      MAX(CASE WHEN Pers='Paul' THEN Rank END) AS Paul,
      MAX(CASE WHEN Pers='John' THEN Rank END) - MAX(CASE WHEN Pers='Paul' THEN Rank END) as Difference
FROM YourTable 
WHERE Pers IN ('John','Paul')
GROUP BY EVT

Thanks in advance

  • 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-18T06:34:15+00:00Added an answer on May 18, 2026 at 6:34 am

    You can add a having clause:

    GROUP BY EVT
    HAVING MAX(CASE WHEN Pers='John' THEN Rank END) IS NOT NULL
           AND MAX(CASE WHEN Pers='Paul' THEN Rank END) IS NOT NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Earlier I asked this question How to correctly unit test my DAL? , one
Possible Duplicate: NoClassDefFoundError - Eclipse and Android I'm seeing this question is getting asked
This question is kind of an add-on to this question In C#, a switch
In the firefox addon update dialog, a message tip will be displayed which can
I'm using Chris Pederick's Firefox addon Web Developer 1.1.6 . I get this warning
I am looking for an addon that can say characters vocally. It is for
What are some resources for getting started writing a Firefox Addon? Is there an
I have the following five tables: ISP Product Connection AddOn AddOn/Product (pivot table for
I'm trying to implement a Visual Studio Addin to support cross-platform development. The addon
The other day, I tweaked a script for a friend's World of Warcraft addon.

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.