sql语句如何写,在线等

yyouyou 2006-03-14 04:34:49
表(a)的内容如下
type color
A red
A green
B yellow

想得到对于A的结果集:

account 状态
2 有

或者 对于C的结果集:

account 状态
C 无

写了一语句,

sql = slect count(*) as account, account>0?'有':'无' as '状态' from a where a.type ='A'

不过不能用:(

求大虾帮忙,先谢谢了。

...全文
65 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyouyou 2006-03-14
  • 打赏
  • 举报
回复
晕,把 cenlmmx(学海无涯苦作舟) 给漏了:(

不好意思啊。
yyouyou 2006-03-14
  • 打赏
  • 举报
回复
呵呵,多谢多谢!运行了一下,要把 状态 的单引号去掉:)
xiaoxiao1984 2006-03-14
  • 打赏
  • 举报
回复
select count(*) as account, decode(sign(count(*)),1,'有','无') as 状态
from a where a.type ='C'
cenlmmx 2006-03-14
  • 打赏
  • 举报
回复
slect count(*) as account, decode(sign(count(*)-1),1,'有','无') as '状态' from a where a.type ='A'

17,377

社区成员

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

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