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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:39:45+00:00 2026-05-23T15:39:45+00:00

ColA ColB ColC ColD data1 rata1 T Test1 data1 rata3 F Test2 data1 rata2

  • 0

ColA ColB ColC ColD
data1 rata1 T Test1
data1 rata3 F Test2
data1 rata2 T Test1
data2 rata1 T Test1
data2 rata3 T Test1
data3 rata4 T Test1

Have four columns of type Varchar. What i wish to determine is:-
1. For each unique value of ColB(rata1, rata2 etc), find corresponding value of ColA and other two columns (ColC, ColD) where that specific value of ColA has ColC value equal to ‘T’ 0 or 1 times.

rata2 data1 T Test1
rata3 data2 T Test1 
rata4 data3 T Test1

2. In the above query when ColC was equal to ‘T’ 0 or 1 times, find other rows for which ColA has ColC equal to ‘F’ for that specific value of ColB.

rata3 data1 F Test2  
  • 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-23T15:39:45+00:00Added an answer on May 23, 2026 at 3:39 pm

    Didn’t understand your question at all. I’ll correct the answer if you say something else. but as far I understood you want something like this?

    Edit: I made the same table that you gave us in a DB. And this worked fine. Try it and tell me if it works

    SELECT COLUMNB,MAX(COLUMNA), MAX(ColumnC), MAX(COLUMND)
    FROM DUMMY
    WHERE ColumnC = 'T'
    GROUP BY COLUMNB
    HAVING SUM(CASE WHEN COLumnC = 'T' THEN 1 ELSE 0 END) <= 1
    
    UNION ALL
    SELECT * 
    FROM  DUMMY
    WHERE COLumnC = 'F'
    

    Edit 2: What about this?

    WITH B
    AS(
    SELECT A.COLUMNB, MAX(A.COLUMNA) AS COLUMNA, MAX(A.ColumnC) AS COLUMNC, MAX(A.COLUMND) AS COLUMND
    FROM DUMMY A
    GROUP BY A.COLUMNB
    HAVING SUM(CASE WHEN A.COLumnC = 'T' THEN 1 ELSE 0 END) <= 1)
    
    
    SELECT * 
    FROM B 
    
    UNION ALL
    SELECT D.COLUMNB, D.ColumnA, D.ColumnC, D.ColumnD
    FROM B, DUMMY D
    WHERE  B.ColumnB = D.COLUMNB
    AND D.ColumnC = 'F'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table like below: ColA ColB ColC ColD ColE ColF Checked
I have a query: SELECT * FROM (SELECT COLA, COLB, COLC, COLD, ROW_NUMBER() OVER(ORDER
Basically, if I have a table with composite indices (colA, colB, colC) and (colB,
I have a table as follows: colA colB(unique) colC --------------------------------- 1 1449 0.50000000 1
I have a table with values ID BarID FName LName ColA ColB ColC 1
I have a stored procedure that returns multiple columns. like colA colB colC ....
Suppose I have a table like this.. ColA ColB ColC ---------------------- A 100 1
I have a table with some data in it: ColA | ColB | ColC
If i have tableA and tableB with three columns: colA | colB | colC
I have two columns. ColA and ColB contains char(10) with data 20090520 and 20090521.

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.