大家好,在这里想请教大家一条SQL语句
我有一个表Wmshandleout,里面大概有800万条记录,Deliverno是送货单号,CreateDate是发货时间,Barcode是货物条形码,Productcode是产品内部编号表如下:
ID BarCode Deliverno Productcode num CreateDate saleType
1 KKK123 D00001 PSR0W001 1 2007-06-04 08:30:00 出口
2 KKK124 D00001 PSR0W001 1 2007-06-04 08:30:30 出口
3 KKK125 D00001 PSR0W001 1 2007-06-04 08:30:50 出口
4 KKC125 D00003 PSR0W003 1 2007-06-04 08:35:01 国内
5 KKC125 D00003 PSR0W004 1 2007-06-04 08:40:00 国内
.....
....
我想查询出同一个送货单号最早的出货时间和最晚的出货时间
如送货单为D00001的最早出货时间为2007-06-04 08:30:00最晚出货时间为2007-06-04 08:30:50
我写了一个语句如下,但是特别的慢,大概执行要20秒钟,各位有没有什么更好的办法?Select Deliverno,min(to_char(createdate,'hh24:mi')) StartCreateDate, max(to_char(createdate,'hh24:mi')) EndCreateDate
From wmshandleout
Where createdate like to_date('2007-05-31','yyyy-mm-dd')
Group By DELIVERNO
我有一个表Wmshandleout,里面大概有800万条记录,Deliverno是送货单号,CreateDate是发货时间,Barcode是货物条形码,Productcode是产品内部编号表如下:
ID BarCode Deliverno Productcode num CreateDate saleType
1 KKK123 D00001 PSR0W001 1 2007-06-04 08:30:00 出口
2 KKK124 D00001 PSR0W001 1 2007-06-04 08:30:30 出口
3 KKK125 D00001 PSR0W001 1 2007-06-04 08:30:50 出口
4 KKC125 D00003 PSR0W003 1 2007-06-04 08:35:01 国内
5 KKC125 D00003 PSR0W004 1 2007-06-04 08:40:00 国内
.....
....
我想查询出同一个送货单号最早的出货时间和最晚的出货时间
如送货单为D00001的最早出货时间为2007-06-04 08:30:00最晚出货时间为2007-06-04 08:30:50
我写了一个语句如下,但是特别的慢,大概执行要20秒钟,各位有没有什么更好的办法?Select Deliverno,min(to_char(createdate,'hh24:mi')) StartCreateDate, max(to_char(createdate,'hh24:mi')) EndCreateDate
From wmshandleout
Where createdate like to_date('2007-05-31','yyyy-mm-dd')
Group By DELIVERNO
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货