请问sql有没什么集合函数直接判断一个列的值是否全部一样---在线等待

jornet 2003-10-13 06:19:44
如果没有,哪有什么简便的方法么?
...全文
101 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jornet 2003-10-14
  • 打赏
  • 举报
回复
程序昨天做好了,我用的max()和min进行比较这样做的
cleanduo 2003-10-14
  • 打赏
  • 举报
回复
select count(distinct col) from tablename;
bzszp 2003-10-14
  • 打赏
  • 举报
回复
select count(select distinct col from tbname)) from dual;
不是很简单吗?
LGQDUCKY 2003-10-14
  • 打赏
  • 举报
回复
用max()和min()也可以用count(distinct c1 )不更好吗?
速度会块很多。
chanet 2003-10-13
  • 打赏
  • 举报
回复
select count(distinct c1 )
------------------------------
哈哈... 够简的 :(
black_snail 2003-10-13
  • 打赏
  • 举报
回复

select count(distinct c1 )
taogenxian 2003-10-13
  • 打赏
  • 举报
回复
你想在程序里用吗?
执行用上面SQL文
select count(*) from tablename group by 列
返回结果保存到变量里不就可以判断了?


beckhambobo 2003-10-13
  • 打赏
  • 举报
回复
select 列 from tablename group by 列 having count(*)>1
Lastdrop 2003-10-13
  • 打赏
  • 举报
回复
count(distinct col)为1表示col所有的值都一样。
jornet 2003-10-13
  • 打赏
  • 举报
回复
要能用存储过程,我就不问咯
伍子V5 2003-10-13
  • 打赏
  • 举报
回复
declare @i int
select @i=count(*) from tablename group by 列
if @i=1
print '全部一样'

可惜是sql server 的语法

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧