ÇóÒ»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
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
ÎÒÒѾ°´Õս̳ÌÉÏÅäÖÃtomcatµÄserver.xml
<Context path = "/POS" docBase = "POS" debug = "5" reloadable = "true" crossContext = "true" workDir = &quo ......
1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......
3̨µçÄÔ£¬ÆäÖÐһ̨×÷ΪMYSQL·þÎñÆ÷£¬ÁíÍâ2̨ΪTOMCAT·þÎñÆ÷¡£
MYSQL·þÎñÆ÷ÀïÓÐÒ»Ìõ¼Ç¼£¬ IDΪ10.
ÏÖÔÚ2̨TOMCATͬʱ£¨100%£©·¢ÆðÐÞ¸ÄMYSQLÀïIDΪ10µÄÄÇÌõ¼Ç¼£¬±ÈÈçÐ޸ĴËID¼Ç¼ÀïijһÏîµÄÄÚÈÝ¡£ ±ÈÈçTOMCAT 1Ò ......
ÎÒÏë²éѯ³öÿÌìÊý¾ÝµÄ×î´óµÄÒ»¸öÖµ¡£±íµÄ¸ñʽÈçÏÂ
±íÃû: hisdata
×Ö¶Î ±àºÅ Öµ ״̬ ʱ¼ä
Id value state dattime
101 32.3 0 ......