求一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
相关问答:
我已经按照教程上配置tomcat的server.xml
<Context path = "/POS" docBase = "POS" debug = "5" reloadable = "true" crossContext = "true" workDir = &quo ......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......
各位兄弟请教 下,在mysql中能不能实现这样一个功能,
一个字段A是储存一大段文字内容的,是英文,能不能通过MYSQL的查询之类的功能,来获得这个字段中 出现频率最高的十个单词,并将这十个单词做为新的字段储存
a ......
下面是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 ......