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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:28:17+00:00 2026-05-27T18:28:17+00:00

I have a query such as this: select a.id, a.color, a.shade from colors a

  • 0

I have a query such as this:

select a.id, a.color, a.shade from colors a where a.color = 'red'

which fetches

ID     | Color      | shade
-------|------------|---------
23     |red         | dark10
525    |red         | light-10

Question:

How can I find all records in table colors where there are multiple (two) occurrences of samecolor AND their corresponding shades are NOT identical

e.g. records like the following will not be considered

ID     | Color      | shade
-------|------------|---------
23     |green       | light-10
324    |green       | light-10
  • 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-27T18:28:17+00:00Added an answer on May 27, 2026 at 6:28 pm

    You can do this by utilizing a GROUP BY clause with a HAVING COUNT(*) = 1 condition:

    declare @colors table (
        id int,
        color nvarchar(100),
        shade nvarchar(100)
    )
    
    insert into @colors
            select 23, 'red', 'dark10'
    union all select 525, 'red', 'light-10'
    union all select 23, 'green', 'light-10'
    union all select 324, 'green', 'light-10'
    
    select c.*
    from @colors c
    inner join (
        select color, shade
        from @colors 
        group by color, shade
        having COUNT(*) > 1
    ) x
        on x.color = c.color
        and x.shade <> c.shade
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this such query : SELECT au_lname,der.col FROM authors INNER JOIN (SELECT t.au_id,
I have a very straight forward select query such as this: SELECT * FROM
If I have a query such as : select * from tbl where id
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
i have this query: select eid from event where creator = 100000956216009 Return this
I have a query which is crossing two tables select count(*) from ingenium.empevt, ingenium.evt
Ok, say I have a join query like this: SELECT users.* FROM users LEFT
I have a query like this: SELECT fields FROM table WHERE field1='something' OR field2='something'
I have a Query Script like this: SELECT View1.OrderDate,View1.Email,SUM(View1.TotalPayments) FROM dbo.View1 WHERE (View1.OrderStatus =
Is it possible to have a query such as the following: SELECT @threadIDvar =

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.