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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:33:02+00:00 2026-06-14T16:33:02+00:00

I have a table of data like this: id user_id A B C =====================

  • 0

I have a table of data like this:

id  user_id  A  B  C
=====================
1   15       1  2  3
2   15       1  2  5
3   20       1  3  9
4   20       1  3  7

I need to remove duplicate user ids and keep the record that sorts lowest when sorting by A then B then C. So using the above table, I set up a temp query (qry_temp) that simply does the sort–first on user_id, then on A, then on B, then on C. It returns the following:

id user_id  A  B  C
====================
1  15       1  2  3
2  15       1  2  5
4  20       1  3  7
3  20       1  3  9

Then I wrote a Totals Query based on qry_temp that just had user_id (Group By) and then id (First), and I assumed this would return the following:

user_id  id
===========
15       1
20       4

But it doesn’t seem to do that–instead it appears to be just returning the lowest id in a group of duplicate user ids (so I get 1 and 3 instead of 1 and 4). Shouldn’t the Totals query use the order of the query it’s based upon? Is there a property setting in the query that might impact this or another way to get what I need? If it helps, here is the SQL:

SELECT qry_temp.user_id, First(qry_temp.ID) AS FirstOfID
FROM qry_temp
GROUP BY qry_temp.user_id;
  • 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-14T16:33:04+00:00Added an answer on June 14, 2026 at 4:33 pm

    You need a different type of query, for example:

    SELECT tmp.id,
           tmp.user_id,
           tmp.a,
           tmp.b,
           tmp.c
    FROM   tmp
    WHERE  (( ( tmp.id ) IN (SELECT TOP 1 id
                             FROM   tmp t
                             WHERE  t.user_id = tmp.user_id
                             ORDER  BY t.a,
                                       t.b,
                                       t.c,
                                       t.id) )); 
    

    Where tmp is the name of your table. First, Last, Min and Max are not dependent on a sort order. In relational databases, sort orders are quite ephemeral.

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

Sidebar

Related Questions

I have table like this: +------+-------+ | user | data | +------+-------+ | 1
I have data that looks roughly like this: user_id range start end 10 500
My table have data structure like this cate_id task_id date_start date_end other 34 14
I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I have a table (call it table myTable). It has the data like this:
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I'm a bit confused on this. I have a data table structured like this:
I have a table like this... CustomerID DBColumnName Data 1 FirstName Joe 1 MiddleName
I like to have a query like this: select data from table where (x
I have a table that has data like below(sorted by date) COL_A | COL_B

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.