如何实现禁用Groupby 实现分组问题

zhuwenli 2014-08-03 12:26:12
小弟碰到一个面试题没答出来想请教一下各位大虾
表结构如下:
product 产品表
pid 编号,primarykey
proname 产品名称 字符 30
coin 价格


Order 订单表
oid primarykey number 编号
pid product表pid的外键
category 客户分类 (A,B,C)三类
cusname 客户名称 字符 50

统计 各个产品的各个客户分类的客户有多少 禁止使用groupby
...全文
342 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuwenli 2014-08-03
  • 打赏
  • 举报
回复
请各位大虾帮忙啊
Gospelanswer 2014-08-03
  • 打赏
  • 举报
回复
子查询或者分析函数应该都可以。分析函数跟group by差不多
美到心痛 2014-08-03
  • 打赏
  • 举报
回复
select a.*, (select count(*) from order where pid=a.pid and category='A' ) A, (select count(*) from order where pid=a.pid and category='B' ) B, (select count(*) from order where pid=a.pid and category='B' ) C from product

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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