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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:06:33+00:00 2026-05-24T09:06:33+00:00

scenario: I have difficulty in building a single query that would display a report

  • 0

scenario: I have difficulty in building a single query that would display a report given the schema. Supposedly, the report to be displayed should follow a computation based on the multiplier. For instance:
user, number of messages x multiplier

what is needed: mysql query that would display the expected query result.

* schema *
table: users
id | name
 1 |  cris
 2 |  dave
 3 |  jona

table: services
id | name
 1 |  standard
 2 |  premium

table: service_users
user_id | service_id | multiplier
 1      |  1         |  1
 1      |  2         |  2
 2      |  1         |  1
 2      |  2         |  2
 3      |  1         |  1
 3      |  2         |  2

table: messages
user_id | service_id | content
 1      |  1         |  howdy
 1      |  1         |  hey
 1      |  1         |  hello
 1      |  2         |  the quantity
 1      |  2         |  insignificant
 2      |  1         |  pill
 2      |  1         |  dock
 2      |  2         |  misty docks
 3      |  1         |  drive
 3      |  2         |  with style
 3      |  2         |  like a hawk
 3      |  2         |  earthling rise

query result should look like this

 user_id | multiplier(1) | multiplier(2) | total
  1     |  3            |  4            |  7
  2     |  2            |  2            |  4
  3     |  1            |  6            |  7
  • 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-24T09:06:35+00:00Added an answer on May 24, 2026 at 9:06 am
    SELECT users.id,
           COUNT( IF( service_users.multiplier = 1, 1, NULL ) AS m1,
           COUNT( IF( service_users.multiplier = 2, 1, NULL ) AS m2
           FROM users, messages, service_users
           WHERE users.id = messages.user_id AND
                 messages.user_id = service_users.user_id
                 messages.service_id = service_users.service_id
           GROUP BY users.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: You have an ASP.Net webpage that should display the next image in a
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Scenario: I have a text file that has pipe (as in the | character)
Scenario: I have a console application that needs to access a network share with
Here's the scenario - I have a C# application that reads from a COM
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Scenario I have two wrappers around Microsoft Office, one for 2003 and one for
Scenario: I have a document I created using LaTeX (my resume in this case),
Scenario: I have an outline where I have links for my menu. Each link
Scenario I have recently graduated from university with a degree in Computer Science. My

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.