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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:44+00:00 2026-05-26T14:29:44+00:00

I would like to identify occurences where there are more than 1 distinct value

  • 0

I would like to identify occurences where there are more than 1 distinct value of an E,F column combination within an A,B,C,D grouping.

For example, given the following data:

SELECT * FROM MyTable   

A          B          C          D          E          F
---------- ---------- ---------- ---------- ---------- ----------
1          1          1          1          A          B         
1          1          1          1          A          B         
1          1          1          2          A          C         
1          1          1          2          A          D  

I want to return

A          B          C          D          
---------- ---------- ---------- ----------     
1          1          1          2         

..because there ar multiple distinct (E,F) combinations within that (A,B,C,D) grouping).

Here’s teh SQL to create your test case!

CREATE TABLE [dbo].[MyTable](
    [A] [nchar](10) NULL,
    [B] [nchar](10) NULL,
    [C] [nchar](10) NULL,
    [D] [nchar](10) NULL,
    [E] [nchar](10) NULL,
    [F] [nchar](10) NULL
) ON [PRIMARY]

GO
INSERT INTO [dbo].[MyTable]([A], [B], [C], [D], [E], [F])
SELECT N'1         ', N'1         ', N'1         ', N'1         ', N'A         ', N'B         ' UNION ALL
SELECT N'1         ', N'1         ', N'1         ', N'1         ', N'A         ', N'B         ' UNION ALL
SELECT N'1         ', N'1         ', N'1         ', N'2         ', N'A         ', N'C         ' UNION ALL
SELECT N'1         ', N'1         ', N'1         ', N'2         ', N'A         ', N'D         '
  • 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-26T14:29:45+00:00Added an answer on May 26, 2026 at 2:29 pm
    SELECT
        A,B,C,D
    FROM
        (
        SELECT
            A,B,C,D,
            ROW_NUMBER() OVER (PARTITION BY A,B,C,D,E,F ORDER BY (SELECT 1)) AS DistinctTuplesLong,
            ROW_NUMBER() OVER (PARTITION BY A,B,C,D ORDER BY (SELECT 1)) AS DistinctTuples
        FROM
            Mytable
        ) T
    WHERE 
        DistinctTuplesLong < DistinctTuples
    

    Edit: used wrong windowing function

    Edit 2: clearer now with sample data

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

Sidebar

Related Questions

I would like to identify binary columns in a data.frame. For example, this table
I would like to know the answer for the following questions: Identify device types
I would like to know if it is possible to identify physical processor (core)
What's the most efficient way to identify a binary file? I would like to
I would like to ignore hidden files when extracting a zip. Is there any
We would like to identify and display the server and port that a Java
For fairly obvious reasons, I would like to identify the best way to remove
Given an HTML page that is a text heavy article, I would like to
I would like to identify linear features, such as roads and rivers, on raster
I would like to be able to identify what the name of the method

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.