易截截图软件、单文件、免安装、纯绿色、仅160KB

求一SQL语句 - 其他数据库开发 / MySQL/Postgresql

有一订单表
SQL code:
t_orders{
oid,
user_id,
booking_time
}


用户拥有的订单数
SQL code:
select o.user_id, count(o.oid) as amount from t_orders o where booking_time between (time1, between2)
group by o.user_id order by amount

====================
user_id amount
10001 1
10002 1
10004 2
10003 3
10007 3
10009 3
10011 3
10005 5
10006 8
10008 8
10010 8

现需统计拥有订单数目相同的用户数
希望结果:
orderAmount users
1 2
2 1
3 4
5 1
8 3

麻烦哪位帮写下能得出上面统计结果的SQL?
SQL code:

select tb.amount,count(*) users from
(select o.user_id, count(o.oid) as amount from t_orders o where booking_time between (time1, between2)
group by o.user_id) tb
group by tb.amount
order by tb.amount;



select amount,count(*) as users from 
(select o.user_id, count(o.oid) as amount from t_orders o where booking_time between (time1, between2)
group by o.user_id) t
group by amount
ord


相关问答:

Asp+sql server问题 - Web 开发 / ASP

我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例: ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

mysql问题! - Java / Java SE

String sqlCount="select count(*) from usertable where username='"+
userName+"'";这句话 什么意思啊!
这句话输出出来就是
select count(*) from usertable where username='你的变量 ......

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号