Find row that has same value in one column over multiple rows while another column has different values

sql select rows with different values in one column
how to vlookup and return multiple corresponding values vertically in excel
vlookup multiple values horizontally
return all rows that match criteria excel
how to select all rows which have same value in some column
excel index match return multiple values in one cell
select rows with same id but different value in another column
excel vlookup same value repeated

Sorry I couldn't demonstrate this on SQLFiddle because it seems to be down when I asked this question.

I have the following table

Col1        Col2     
====        ====     
1           A       
1           A       
1           B    
2           C
2           C

If I run the group by query of


I would get

Col1        Col2     
====        ====     
1           A            
1           B    
2           C

My question is how can I write a query to detect column 1 value when I have more than one different values in column 2? Essentially the return of that query should give me "1" because that is where the rows have the same value in Col1 while Col2 have different values over the span of multiple data rows.

You can use group by clause with min() and max() :

select col1
from table t
group by col1
having min(col2) <> max(col2);

Get rows having different values for a column based on the duplicate , Using standard SQL on most RDBMS, there are various ways. COUNT(distinct DEF) > 1 ) dup ON dup.dept = d.dept AND dup.role1 = d.role1 AND dup.role2 = d.​role2 ;. The subquery returns sets of dept/role1/role2 with more than 1 rows. If at least one row exists, the row from the main table is returned. Check if one column value exists in another column using MATCH. You can use the MATCH() function to check if the values in column A also exist in column B. MATCH() returns the position of a cell in a row or column. The syntax for MATCH() is =MATCH(lookup_value, lookup_array, [match_type]).

Try this:

select Col1,count(distinct Col2) as [different Col2 value count]
from yourtable
having count(distinct Col2)>1

Formula to check if rows that have the same value in one column , This will count the matching column B & column C values. Then eliminate all rows with result greater than 1 to find unique values. Section: Excel Basics Tutorial: Autofill Row or Column - Same Data. Excel: How to FILL a Column, Row, Range with the SAME DATA. We often want to copy and paste data into other worksheet cells - perhaps part of a row or column, a cell range, or non-adjacent cells. We can do this easily in Microsoft Excel. We can also have Excel autofill

       FROM table t1 
            JOIN table t2 
                  ON T1.col1 = T2.col1 AND T1.col2 != T2.col2

Match two criteria and return multiple records, I have a table of 3 columns (Security name, date, price) and I have to find the to extract records/rows based on two conditions applied to two different columns, you cell value G3 lets you match values in column B and cell G4 matches dates in ROW($B$3:$D$19)-MIN(ROW($B$3:$D$19))+1), ROW(A1)), COLUMN(A1))​  This lesson shows you how to use the INDEX function (plus some other functions) to find all matching values in a list, and return a value from another column in the same row. It also looks at how to do this when you want to return all values which are a partial match (i.e. a wildcard search) to the values in your lookup table.

5 easy ways to VLOOKUP and return multiple values, The VLOOKUP function is designed to return only a corresponding value of the first and return multiple values distributed over several columns, the formula even Another great thing with this array formula is that it allows you to lookup and points to a cell range containing multiple rows so the ROW function returns an  Extract all rows from a range that meet criteria in one column [Filter] The image above shows filtered records based on two conditions, values in column D are larger or equal to 4 or smaller or equal to 6.

Excel: Compare two columns for matches and differences, Enter the formula in some other column in the same row, and then copy it Find rows with the same values in all columns (Example 1); Find rows with the formula searches across the entire column B for the value in cell A2. Recently, Microsoft has introduced the XLOOKUP function (currently it's only available to Office 365 subscribers who are part of the Office Insiders program). XLOOKUP is able to return more than one value relating to the same match. Here's an example: XLOOKUP to return multiple columns or rows.

Excel unique / distinct values: how to find, filter, select and highlight, Before moving further, let's make sure we are on the same page with the terms. Find unique / distinct values in column; Find unique and distinct rows; Find an Excel conditional formatting rules based on another cell value. that row is "​Pass", you can enter the following formula in row 2, and then copy it  Each row has data based on the ID#, there are multiple rows for each ID# but I want one row per ID# with all of the other data in columns (it would be 5 columns long minimum and 25 maximum depending on how many each unique ID has).

  • Do you mean: return all Col1s that have 2 or more Col2 values?