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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:05:14+00:00 2026-05-21T02:05:14+00:00

I have a table that contains votes that users make on their friends. It

  • 0

I have a table that contains votes that users make on their friends.

It is setup like this:

+------------+------------+------------+------+
| user_id    | friend_id  | contender  | vote | 
+------------+------------+------------+------+
| 1695929578 | 1695529606 | 1695529577 |    1 | 
| 1695929578 | 1695529577 | 1695529606 |    0 |
| 1695929578 | 1695529721 | 1695529578 |    1 |
| 1695929578 | 1695529578 | 1695529721 |    0 |
| 1695929578 | 1695529580 | 1695529606 |    1 |
| 1695929578 | 1695529606 | 1695529580 |    0 |
| 1695929578 | 1695529606 | 1695529578 |    1 |
| 1695929578 | 1695529578 | 1695529606 |    0 |
| 1695929578 | 1695529577 | 1695529721 |    1 |
| 1695929578 | 1695529721 | 1695529577 |    0 |
+------------+------------+------------+------+

Each time a vote is made by the user (user_id) two rows are inserted. One row for the person who got the vote (vote = 1) and that persons contender, and then another row for the person who lost (vote = 0) and their contender.

With one query I want to be able to pass the users friends and get back how many votes are FOR and TOTAL votes for each distinct friend. It would return something like this:

+------------+-------------+
| family_id  | total_votes |
+------------+-------------+
| 1695529439 |           9 |
| 1695529577 |           9 |
| 1695529578 |           6 |
| 1695529580 |           7 |
| 1695529581 |           5 |
| 1695529606 |           7 |
| 1695529721 |           7 |
+------------+-------------+

The only difference is I want an extra column that will contain the votes_for that person so I can compare how many times they were contended to how many times they won.

Any ideas?

  • 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-21T02:05:15+00:00Added an answer on May 21, 2026 at 2:05 am

    Count() will give you total number of votes. Sum() will give you total of favorable votes. Is there something I’m missing?

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

Sidebar

Related Questions

I have a table that contains all the data about users . Users can
I have a table that contains userids and their score. eg. userid rating 123
I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start:
I have a table that contains id, created, user_id. I'm wondering if there is
I have a table that contains some user data: user_id | guest_id | time_seen
I have a table that contains many rows of SQL commands that make up
I have a table that contains information for 4 electrical generators. I would like
I have a table that contains some duplicate redords. I want to make records
I have a table that contains some sensitive data that I would like to
I have a table that contains multiple dropdown menus for a list of profile

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.