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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:15:55+00:00 2026-06-15T13:15:55+00:00

SQL Server 2012 We have a table, like such: ticket, type —————— 1234, hardware

  • 0

SQL Server 2012

We have a table, like such:

ticket, type
------------------
1234, hardware
1543, software
8859, network
5832, hardware
4900, hardware
8403, software
7859, network
4332, telephone
8721, database

Our goal is to count up all tickets belonging to each type (so in this case the result should be 3 hardware, 2 software, 2 network, 1 telephone and 1 database ticket(s)), order them desc and select the first 5 resulting rows.

We’re trying to determine the top 5 “popular” or most seen ticket types (and how many there are).

I’ve got the counting portion down but not sure how to proceed with ordering desc and selecting the first 5.

Thank you!

  • 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-15T13:15:56+00:00Added an answer on June 15, 2026 at 1:15 pm

    In SQL Server you can use TOP to select a certain number of rows along with an order by to get the proper records:

    select top 5 type, count(*) Total
    from yourtable
    group by type
    order by total desc
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

I have a table which stores a SQL predefined function, like CONVERT(VARCHAR(10), '2012-08-21 00:16:41.993',
I have a SQL Server 2008 table with a DateTime column that I'd like
I have an SQL Server 2008 table that can be illustrated as such: CREATE
I'm using ssis 2008 and sql server 2012. I have a table with column
I have a table in SQL Server 2012 that contains patch notes for different
I am using SQL Server 2012 I have a table called AMOUNTS and a
I have installed the following components of SQL Server 2012: management tools - complete
We have an issue upgrading to SQL Server 2012. I am using the following
I have table the following data structure in SQL Server: ID Date Allocation 1,
SQL Server 2000 I have a table which lists out the months where a

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.