请教一个问题,我想用SQL做一个统计:

thedogstar 2000-07-21 08:34:00
请教一个问题,我想用SQL做一个统计:
select count(distinct "worker"."age","worker"."job")
into :l_count
from "worker" ;
统计WORKER里面不重复(年龄、职位)的人共多少,可是上面
的SQL语法错误,
select count(distinct "worker"."age")
into :l_count
from "worker" ; 这句语法正确,两个迭加就不行,
特请教。
...全文
181 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huntout 2000-07-21
  • 打赏
  • 举报
回复
count(distinct expression) expression只能是一個表達式
將兩個字段組合起來就行了

select count(distinct convert(varchar, "worker"."age") + "worker"."job")
into :l_count
from "worker" ;
語法不一定正確,希望有幫助 :p
zy 2000-07-21
  • 打赏
  • 举报
回复
select count(distinct "worker"."age","worker"."job")
into :l_count ,:j_count
from "worker" ;
thedogstar 2000-07-21
  • 打赏
  • 举报
回复
谢谢大家了。
tanghuan 2000-07-21
  • 打赏
  • 举报
回复
select count(*)
from (
select distinct "worker"."age","worker"."job"
from "worker" ) as aa ;

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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