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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:28:16+00:00 2026-06-04T12:28:16+00:00

I just need a sql server query for following scenario: Need a query to

  • 0

I just need a sql server query for following scenario:

enter image description here

Need a query to get a single record of each vehicle type.

I have a table of Vehicle.

Passenger Car, Pickup Truck, MPV are the vehicle type.

There are 4 record of Passenger Car, 2 records of Pickup Truck and a record of Multipurpose Vehicle (MPV).

so I want a query to get the single record of each type.

Thanks

My desire output:

ID Model               VehicleType           Owner
1  LTD Crown Victoria  Passanger             XXXXXXXXXX
2  Tacoma              Pickup                YYYYYY
3  Explorer            Multipurpose Vehicle

This kind of output that I want.

  • 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-04T12:28:17+00:00Added an answer on June 4, 2026 at 12:28 pm

    Try

    SELECT DISTINCT [Vehicle Type] FROM your_table
    

    I see your edits. This query gives you exactly what you ask:

    WITH t1 AS
    (
      SELECT
        ID, Model, [Vehicle Type], Owner,
        RANK() OVER(PARTITION BY [Vehicle Type] order by ID) AS t2
      FROM your_table
    )  
    SELECT ID, Model, [Vehicle Type], Owner
    FROM t1
    WHERE t2 = 1
    

    Check it here

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

Sidebar

Related Questions

I have a SQL Server table that contains the following fields: SessionId (guid) Message
I have a SQL Server table. I need to create the same table in
i have the following table data in ms sql server table name category and
I have a SQL Server 2008 database with the following information in a table:
A table exists in Microsoft SQL Server with record ID, Start Date, End Date
I am trying to execute a query on a table in my SQL Server
Using Sql-Server 2005. I have Users table with 3 columns. userID, parentUserID and userEmail.
I need some help in explaining this behavior in SQL Server 2008. I have
While the following work fine in SQL Server Management Studio, it just won't work
Using SQL Server 2008, I have abc and xyz table abc abc_id | xyz_id1

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.