字段1 字段2 字段3 A B C A B C 如何用SQL判断返回知道 字段2是否相等 字段3是否相等 记录只有两条 感觉是太容易了,还是太难了?还是没说清楚? 你要这么返回?
having count(distinct 字段1)=1 ? SQL code:
if exists(select 1 from tb where 字段1='A' and 字段2=字段3) begin do sth... end
SQL code: select COL='字段1',flag=case when COUNT(distinct 字段1)=1 then '相等' else '不相等' end from tb union select COL='字段2',flag=case when COUNT(distinct 字段2)=1 then '相等' else '不相等' end from tb union select COL='字段3',flag=case when COUNT(distinct 字段3)=1 then '相等' else '不相等' end from tb
定! SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware) http:/