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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:11:51+00:00 2026-06-04T20:11:51+00:00

I have a sales table with the below columns name type (student, adult, worker)

  • 0

I have a sales table with the below columns

  • name
  • type (student, adult, worker)
  • sales (A,B,C,D)
  • cost
  • location (1,2,3,4)

i want to get the count of type, sales and location which is relevant to the name and group by the name so i can display it on a table
enter image description here

is it possible get all the grouped values using a query>

any help willbe appreciated..

  • 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-04T20:11:52+00:00Added an answer on June 4, 2026 at 8:11 pm

    Use GROUP BY and then SUM(condition) to obtain your counts:

    SELECT   name AS Name,
             SUM(type     = 'worker' ) AS Worker,
             SUM(type     = 'student') AS Student,
             SUM(type     = 'adult'  ) AS Adult,
             SUM(sales    = 'A'      ) AS A,
             SUM(sales    = 'B'      ) AS B,
             SUM(sales    = 'C'      ) AS C,
             SUM(sales    = 'D'      ) AS D,
             SUM(location = 1        ) AS Location1,
             SUM(location = 2        ) AS Location2,
             SUM(location = 3        ) AS Location3,
             SUM(location = 4        ) AS Location4
    FROM     sales
    GROUP BY Name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I have an SQL table like this : sales(product,timestamp) I want to display a
I have sales table data as shown below Sales Table Data http://lh5.ggpht.com/_KT7tmVVBHFM/TCryAax1JlI/AAAAAAAAAFk/zahMq4RoOuw/s144/Sales.png I want
I have a table Sales with the following fields: code, amount, index, name .
I have a large table with sales data, useful data below: RowID Date Customer
I need a little help brainstorming on a query. I have a sales table
I have 2 tables like this: Stock Table product_id bigint(20) qty float Sales Table
I have a table with sales per store as follows: SQL> select * from
I have a table of products sales that may look as follows: product |
I have one table that has sales records and another table that has additional

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.