var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Select if all values equal
What I'd like to do is select distinct values for one field if ALL values for another field are identical - like this:
SELECT DISTINCT A, B FROM TABLE WHERE (ALL B=1)
could you repeat the question please?
perhaps with a better example
I want to select distinct values in column A (which holds names), but only if all the values in column B (which holds numerical values) = 1. So if there's a single record in column B holding any value other than a "1", the name in column A should not be shown.
HAVING 0 = COUNT(CASE WHEN b <> 1 THEN 'uh oh' END)
Sorry, No Go
It doesn't work (freezes the w3wp.exe), but thanks for trying. By the way, I visited the Simply SQL to check out your book but there are no links there.
it wasn't just "trying" -- that's the solution for the problem you posted
at least, for this problem
if it's actually related to your other problem then i'm afraid i don't understand either of them
and yes, i know there's no link there, but it's a long story
Seems pretty straightforward:
SELECT DISTINCT A FROM TABLE WHERE B=1
Tags for this Thread