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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:24:28+00:00 2026-05-22T11:24:28+00:00

Hey guys, I need some help with this. I have a table with about

  • 0

Hey guys, I need some help with this. I have a table with about 100k records. Each row is referenced by an ID. Here is an example

Keyword     | Domain          | Page | UserID
Hello       | www.example.com |    1 |   994
World       | www.example.com |    1 |   994
Genius      | www.example.com |    1 |   994
Example map | www.example.com |    2 |   994
Hello       | www.example.com |    1 |   994
demo0       | www.test.com    |    1 |   994
demo1       | www.test.com    |    2 |   994
demo2       | www.test.com    |    2 |   994
demo3       | www.test.com    |    3 |   994
wonderful   | www.mysql.com   |    1 |   997
wonder      | www.mysql.com   |    1 |   997
SOFLOW      | www.mysql.com   |    1 |   997

What I want to see is how many (single number) keywords appear on Page 1, 2 or 3 for a user.

Here is an example output:

User | Domain          | Total KW | #Page 1 | #Page 2 | # Page3
 994 | www.example.com |        5 |       3 |       1 |       0
 994 | www.test.com    |        4 |       1 |       2 |       1

I know I can do this in PHP, but is there any way to do this in MySQL? I can get the avg and the count but I cant get what I want 🙁

Any help is much appreciated. Thanks.

  • 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-22T11:24:29+00:00Added an answer on May 22, 2026 at 11:24 am
    SELECT User, Domain, COUNT(Page),
        SUM(IF(Page=1, 1, 0)) AS Page1,
        SUM(IF(Page=2, 1, 0)) AS Page2,
        SUM(If(Page=3, 1, 0)) AS Page3
    FROM table
    GROUP BY User, Domain
    

    This would get tedious if there’s more than just these 3 “pages”. At that point you should just group on the page as well, count them normally without the SUM stuff, and then do the multi-column formatting in your application.

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

Sidebar

Related Questions

Hey guys I need some help with this: I have two view controllers, let's
Hey guys need some more help I have 3 tables USERS, PROFILEINTERESTS and INTERESTS
Hey guys i need some help with logic in my app. I have an
Hey Guys, here is my code for this, the only help i get from
hey guys, I need help considering win32com in Python: I have a routine that
Hey, i need some help with rails, again ! Last it was about Authlogic..
Hey guys! I need some help writing a code that creates an array in
Hey guys, i'm having some trouble with this: In the object consumer i need
Hey guys, I need some help, how can I sum a list from a
Hey guys, if anybody can help me out i'd love it... What i have

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.