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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:51:51+00:00 2026-06-06T06:51:51+00:00

I want to select distinct or unique records from a database I am querying.

  • 0

I want to select distinct or unique records from a database I am querying. How can I do this but at the same time select the entire record instead of just the column that I am distinguishing as unique? Do I have to do unruly joins?

  • 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-06T06:51:53+00:00Added an answer on June 6, 2026 at 6:51 am

    If you want only one column out of several to be unique and you have joins that might include multiple records, then you have to determine which of the two or more values you want the query to provide. This can be done with aggregate functions, with correlated sub-queries or derived tables or CTEs (In SQL Server not sure if Oracle has those).

    But you have to determine which value you want before you write the query. Once you know that then you probably know how to get it.

    Here are some quick examples (I used SQL Server coding conventions but most of this should make sense in Oracle as it is all basic SQL, Oracle may have a different way of declaring a parameter):

    select a.a_id, max (b.test) , min (c.test2)
    from tablea a 
    join tableb b on a.a_id = b.a_id
    join tablec c on a.a_id = c.a_id
    group by a.a_id
    order by b.test, c.test2
    
    Select a.a_id, (select top 1 b.test from tableb b where a.a_id = b.a_id order by test2),
    (select top 1 b.test2 from tableb b where a.a_id = b.a_id order by test2),
    (select top 1 c.test3 from tablec c where a.a_id = c.a_id order by test4)
    from tablea a   
    
    declare @a_id int
    set @a_id = 189
    select a.a_id , b.test, b.test4
    from tablea a 
    join tableb b on a.a_id = b.a_id
    join (select min(b.b_id) from tableb b where b.a_id = @a_id order by b.test3) c on c.b_id = b.b_id
    where a.a_id = @a_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select unique images from a database. I am using the following
I have this query SELECT ann_arr.id,ann_arr.user_id,ann_arr.date,ann_arr.time, ann_arr.venue_id FROM ann_arr WHERE user_id IN (SELECT DISTINCT
I want to select a view from my sys user, but with other connection.
Is something like this possible: SELECT DISTINCT COUNT(productId) WHERE keyword='$keyword' What I want is
I want to select the entire first row of each record where a promo
Say I have y distinct values and I want to select x of them
i have users table and i have posts table i want select from users
I want to SELECT a formatted date string from a datetime type in SQL
I want to select all categories from a webservice. The webservice does not have
I want to select information in a single cell from my DataGrid in Flex

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.