Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if all the cells have the same value in some column

How to know if all the cells have the same value in some column (title changed)

I want to have a bit scalar value that tells me if all the values in a column equal something:

DECLARE @bit bit
SELECT @bit = TRUEFORALL(Name IS NOT NULL) FROM Contact

UPDATE

I now realized that I actually don't need the TrueForAll, what I do need is to make sure, that all values in a column are equal, for example, I want to know whether all Group.Items have the same price.

like image 242
Shimmy Weitzhandler Avatar asked Dec 23 '09 01:12

Shimmy Weitzhandler


People also ask

How do you find if same value exists in another column Excel?

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]) . Using MATCH, you can look up a value both horizontally and vertically.


1 Answers

Why not?

select count( distinct price) from table

If returns 1, all values are the same... Add

where price is not null

if need be

like image 138
Sparky Avatar answered Oct 19 '22 01:10

Sparky