select (case when a>b then (select count([a]) from [product])
when b>c then (select count([b]) from [product])
else (select count([c]) from [product])
end ) as your
when b>c then (select count([b]) from [product])
else (select count([c]) from [product])
end ) as your
when b>c then (select count([b]) from [product])
else (select count([c]) from [product])
end ) as your
我是比较state 如果是'CA' 那么在下面再判断if那些哦。
CASE state
WHEN 'CA' THEN (SELECT COUNT(case when a>b then a when b>c then b else c end) FROM [Product])
WHEN 'KS' THEN 'Kansas'
WHEN 'TN' THEN 'Tennessee'
WHEN 'OR' THEN 'Oregon'
WHEN 'MI' THEN 'Michigan'
WHEN 'IN' THEN 'Indiana'
WHEN 'MD' THEN 'Maryland'
WHEN 'UT' THEN 'Utah'
END AS StateName
FROM pubs.dbo.authors
ORDER BY au_lname