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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:46:30+00:00 2026-06-13T23:46:30+00:00

Using a distinct query with a case-insensitive collation like SQL_Latin1_General_CP1_CI_AS will retrieve the first

  • 0

Using a distinct query with a case-insensitive collation like SQL_Latin1_General_CP1_CI_AS will retrieve the first occurrence of any case-insensitive rows.

But I want to retrieve the lower case if both cases are present.

If only one case is present in the data I want to retrieve that case. (unique occurrences of capital case should remain in capital case in the result set)

Table:

id | col1  
----------
1 | Ab  
2 | ab  
3 | cd  
4 | Cd  
5 | Ef 

Query:

SELECT DISTINCT [col1] COLLATE SQL_Latin1_General_CP1_CI_AS 
FROM dbo.table

Will retrieve: Ab, cd, Ef

But I want to retrieve: ab, cd, Ef

Are there collation that can give me my desired results?

Give priority to lower case instead of first case.

If not I have to use subselects.

  1. Select all distinct values using case-sensitive collation (strangely is automatically sorted, almost the use case I wanted!)
  2. Select from 1 using case-insensitive collation
  • 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-13T23:46:32+00:00Added an answer on June 13, 2026 at 11:46 pm

    May be something like this

    select
        min(T.col1 collate SQL_Latin1_General_CP1_CS_AS)
    from dbo.Table as T
    group by T.col1 collate SQL_Latin1_General_CP1_CI_AS
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this query: SELECT DISTINCT pat.PublicationID FROM dbo.PubAdvTransData AS pat INNER JOIN
I'm looking for help using sum() in my SQL query: SELECT links.id, count(DISTINCT stats.id)
I want to remove duplicates from my DataTable so I'm using DataTable.AsEnumerable().Distinct(DataRowComparer.Default) but it
I would like to create a functionality DISTINCT keyword of mysql in c++ using
I have sql query in which i want return rows with distinct value order
This is my base query select distinct a.projects , case when(billing_fy!=0) then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from
Based on my previous question I am running a query like so: SELECT DISTINCT
We're using PostgreSQL v8.2.3. Is it possible to get DISTINCT rows from an UPDATE
I'd like to know if there is any function for Xquery similar to distinct-values
Using SQL Server 2000 How to avoid the duplicate values? Query SELECT DISTINCT Modification.dbo.Reference.Dates

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.