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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:38:42+00:00 2026-06-10T01:38:42+00:00

I have the following query which groups all entries in a MySQL table by

  • 0

I have the following query which groups all entries in a MySQL table by the Name column:

"SELECT * FROM visits GROUP by Name"

I use this to generate a row in an html table for each Name returned. I would like to set the rowspan of the first cell in each of these rows (which contains the name) to the count of the number of unique entries for each name in a second column in the same table called “Page”, and I presume that I would need to do this using the same query.

So, for example, if there were 50 entries/rows in the MySQL table ‘visits’ for the Name ‘Nick’, and five distinct values in the column ‘Page’ for Nick, the markup generated would be:

<tr><td rowspan="5">Nick<td>....

How would I write the query to achieve both these aims?

  • 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-10T01:38:44+00:00Added an answer on June 10, 2026 at 1:38 am

    You can solve this by using COUNT(DISTINCT column).

    SELECT Name, COUNT(DISTINCT Page) AS Page_Distinct FROM visits GROUP BY Name
    

    Tested locally, and it gives the correct result.

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

Sidebar

Related Questions

I have following query which groups and counts entries for each day : SELECT
I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees
I have the following query which works: SELECT ?page ?lat ?long (bif:st_distance(?geo, bif:st_point(42.883, -72.8981)))
I have the following mysql query which I am running with php like so.
I have the following query which returns the salary of all employees. This work
i have the following SQL Query which runs on SQL Server CE 4 SELECT
I have the following query: SELECT m.*, COUNT(c.chapter_nr) as chapters, MAX(c.chapter_nr) as latest_chapter FROM
At the moment I have the following MySQL query: SELECT COUNT(*) AS `count`, `v`.`value`
I have the following mysql query which is taking about 3 minutes to run.
I have the following query select count(trade_sid), shortcode from trade where trade.trade_date <= sysdate

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.