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

Here's the scenario - I have a C# application that reads from a COM
We have a scenario where on the product page we have a few text
Here's the scenario. Two identical databases: One Live database, one Archive database, they're suppose
In my scenario, let's say there is a ASP.Net 4.0 C# page containing a
I've been research WIF a lot recently and am still quite a bit confused
Sorry if the title is confusing, I am finding it difficult to clearly word
I need to know if it is possible to run powershell remotely in the
Our project has about 20 developers, but our application makes relatively light use of
I am developing a system which needs to allow users to be placed into

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.