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

  • Home
  • SEARCH
  • 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 366817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:40:07+00:00 2026-05-12T13:40:07+00:00

My boss has given me an assignment that I’m not sure is possible since

  • 0

My boss has given me an assignment that I’m not sure is possible since after about two weeks, I can’t figure out a solution, so I’m throwing this out to ask for any sort of help from the SO group. If this breaks your brain, I apologize.

A little background first: We develop a database querying application that allows users to get back anything they want from the database without having to know any SQL.

My Problem: We want to customize way a “Distinct” selection is used. Instead of having the distinct keyword apply to the rows selected, we want it to apply to only certain fields, so that the first rows that match the fields will get used. For an example:

Bob Jones, 122 Main Street, Portland, OR
Sue Jones, 122 Main Street, Portland, OR
Mary Smith, 458 32nd Street, Portland, OR
Ralph Smith, 458 32nd Street, Portland, OR

we want this to work so that only the first rows for each address is returned as follows:

Bob Jones, 122 Main Street, Portland, OR
Mary Smith, 458 32nd Street, Portland, OR

With the normal distinct, all four rows would be returned, which is more than we want. Does anyone have any ideas as to how we can go about doing this? Thanks.

  • 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-05-12T13:40:07+00:00Added an answer on May 12, 2026 at 1:40 pm
    WITH NumberedRows AS (
       SELECT FirstName, LastName, Address,
              ROW_NUMBER() OVER (PARTITION BY Address ORDER BY Id) as RowNumber
       FROM Table
    ) SELECT FirstName, LastName, Address
      FROM NumberedRows
      WHERE RowNumber = 1;
    

    PARTITION BY Address specifies the column list you want to group by, and ORDER BY ID indicates the column list you define the “first” item with.

    (Make sure the previous statement is terminated by a semicolon.)

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

Sidebar

Related Questions

My boss has asked for a page that will not change to have two
Let's say at your job your boss says, That system over there, which has
My boss has a habit of performing queries on our databases that return tens
My boss has come to me and asked how to enure a file uploaded
I've got an angry boss that will beat me down if I waste another
I got into a mini-argument with my boss recently regarding project failure. After three
I've got a little stuck here. My boss has asked me to look into
I have a data entry web app where the control that has focus is
First a little about myself. I am not an experienced software engineer, architect or
Im developing a web application in asp.net mvc (c#) that has a form and

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.