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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:41:41+00:00 2026-06-01T02:41:41+00:00

I have a user table like this FIRSTNAME | LASTNAME | ID | ——————————–

  • 0

I have a user table like this

FIRSTNAME  |  LASTNAME  |  ID  |
--------------------------------
James      |  Hay       |  1   |
Other      |  Person    |  2   |

I also have an attendance table like this

EVENTID  |  USERID  |  ATTENDANCE  |  STATUS  |
-----------------------------------------------
1           1          True           3
2           1          False          1
3           1          False          3
1           2          False          1
2           2          True           3
3           2          True           3

Basically, when a user is invited to an event, a row is added to the attendance table which has the event ID, their user ID, false attendance, and status 0.

Status is just an indicator of their response

0 = No Response
1 = Said No
2 = Said Yes
3 = Said yes and seats confirmed

My end result I want to get from querying these two tables is quite complicated and I can’t figure out what I need to do.

I want to get a result like this

NAME          |  % of saying YES to an RSVP  | % of attending after saying yes
-------------------------------------------------------------------------------
James Hay     |             66               |                50
Other Person  |             66               |                100

I’m sure you can work out how I got those numbers but to explain, James Hay had the 3 (yes) status to 2/3 events invited to. So % of saying yes is 66. Out of the 2 he said yes to, he only attended 1/2 so % of attending after saying yes is 50%

Any push in the right track would be much appreciated here since I can’t get my head around this.

EDIT:

Also something quite important is that I want the results to include every user in the database even if they have 0 rows in the attendance table.

  • 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-06-01T02:41:43+00:00Added an answer on June 1, 2026 at 2:41 am
    SELECT A.NAME,B.PERCENTAGE_YES_RSVP,B.PERCENTAGE_AFTER_YES
    FROM 
    ( 
      SELECT U.ID AS ID,U.FIRSTNAME+''+U.LASTNAME AS NAME
      FROM USERS U
    ) A,
    (
      SELECT A.USERID,A.PERCENTAGE_YES_RSVP,B.PERCENTAGE_AFTER_YES
    FROM   
      (
        SELECT B.USERID,ROUND((CAST(B.COUNT_YES_RSVP AS FLOAT)/B.TOTAL_COUNT)*100,0) AS PERCENTAGE_YES_RSVP    
        FROM  
        (SELECT A.USERID,
           SUM(CASE WHEN A.STATUS=3 THEN 1 END)AS COUNT_YES_RSVP,
           COUNT(*) AS TOTAL_COUNT
           FROM ATTENDANCE A  
           GROUP BY A.USERID
         ) B
      ) A,  
    (
      SELECT C.USERID,(CAST(C.COUNT_AFTER_YES_RSVP AS FLOAT)/C.TOTAL_COUNT)*100 AS PERCENTAGE_AFTER_YES   
      FROM  
      (SELECT A.USERID,
           SUM(CASE WHEN A.STATUS=3 AND A.ATTENDANCE='TRUE' THEN 1 END)AS COUNT_AFTER_YES_RSVP,
           SUM(CASE WHEN A.STATUS=3 THEN 1 END) AS TOTAL_COUNT
       FROM ATTENDANCE A  
       GROUP BY A.USERID
       ) C
    )B   
    WHERE A.USERID=B.USERID
    ) B
    WHERE A.ID = B.USERID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this person table as super parent, id firstname lastname email telephone ...
I have an user table like this:- guid | username | password | firstname
Suppose you have a table like this: id user score It's a dump of
I have a table which stores test results like this: user | score |
I have a table like: | id | lastname | firstname | | 1
I have table in my database names User with fields: Id FirstName LastName LoginName
I have a table like this: a | user_id ----------+------------- 0.1133 | 2312882332 4.3293
I have a couple of tables which look like this Table 1 user_id |
I have a user table 'users' that has fields like: id first_name last_name ...
I have a table like so: Table eventlog user | user_group | event_date |

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.