Çë½ÌÒÔϽá¹ûÓÃSQLÔõÑùʵÏÖ£¿
ÔʼÊý¾ÝÈçÏ£º
Éú²úÄÜÁ¦£¨cap£© ¿ª¹¤ÈÕÆÚ£¨start£© Í깤ÈÕÆÚ(end) Éú²ú¹¤Ê±(hour)
8 2010-1-21 2010-1-25 20
8 2010-1-21 2010-1-26 25
ÒªµÃ³öÒÔÏÂÊý¾Ý
Éú²úÄÜÁ¦£¨cap£© Éú²úÈÕÆÚ Ã¿ÈÕÉú²ú¹¤Ê±(hour)
8 2010-1-21 8.17
8 2010-1-22 8.17
8 2010-1-23 8.17
8 2010-1-24 8.17
8 2010-1-25 8.17
8 2010-1-26 4.17
ÿÈÕÉú²ú¹¤Ê±µÄ¼ÆËã·½·¨Îª£ºµÚÒ»ÐеÄÿÈÕÆ½¾ù¹¤Ê±¼ÓÉϵڶþÐеÄÿÈÕÆ½¾ù¹¤Ê±£¬¼´
8.17=20/5+25/6 4.17=25/6
û¿´¶®
»Ø¸´ÄÚÈÝÌ«¶ÌÁË£¡
SQL code:
create table # (cap int, start datetime, [end] datetime, [hour] int);
insert into #
select 8, '2010-1-21', '2010-1-25', 20 union all
select 8, '2010-1-21','2010-1-26',25;
select cap, DATEADD(DD, v.[number], [start]) [date],
SUM(ROUND([hour]*1.0/(datediff(dd,#.[start],#.[end])+1),2)) [hour]
from master.dbo.spt_values v join #
on v.[number] <= datediff(dd,#.[start],#.[end])
where v.type = 'P'
group by cap, DATEADD
Ïà¹ØÎÊ´ð£º
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
±í
id bh
1 10
2 11
3 12
4 15
5 16
6 22
7 25
8 26
9 27
10 28
½«bh°´Á¬Ðø·Ö¶Î³öÀ´·µ»Ø×Ö·û´®£º
10~12£¬15~16£¬22£¬25~28
SQL code:
declare @t tabl ......
ÈçºÎÔÚSQL2005ÖÐÉ趨¶¨Ê±×÷Òµ£¬±ÈÈç˵¶¨Ê±ÇåÀíijЩ±íµÄÊý¾Ý£¬
»òÕßÊǶ¨Ê±µÄ½«Ä³Ð©±íµÄÊý¾Ýµ¼³öexcel£¡
ÔÚÏߵȴý£¬¼±¼±¼±£¬×îºÃÊÇÏêϸ²½Ö裡
֮ǰÎÒ×öµÄ×÷ÒµÓеãÎÊÌ⣡
°ïUP
²Î¿¼:http://hi.baidu.com/toiota ......