select a.oilno,a.gowordnum,b.liter_total1,c.oilbackliter from oilstationteam a,oilpost_stat b,backcandaystat c
where a.nodeno=b.nodeno and a.nodeno=c.nodeno and convert(char(10),a.opedate,111)=convert(char(10),b.opedate,111) and convert(char(10),a.opedate,111)=convert(char(10),c.accountdate,111) and a.oilno=b.oilno and a.oilno=c.oilno and a.nodeno='14000697' and convert(char(10),a.opedate,111)='2006/10/14'
where a.nodeno=b.nodeno and a.nodeno=c.nodeno and convert(char(10),a.opedate,111)=convert(char(10),b.opedate,111) and convert(char(10),a.opedate,111)=convert(char(10),c.accountdate,111) and a.oilno=b.oilno and a.oilno=c.oilno and a.nodeno='14000697' and convert(char(10),a.opedate,111)='2006/10/14'
oilno gowordnum liter_total1 oilbackliter
-------- ------------------ --------------- ---------------
60000305 1514.64 2802.97 40.00
60000305 1328.33 2802.97 40.00
60000313 1199.98 1179.98 20.00但这不是我想要的。。我要的是
oilno gowordnum liter_total1 oilbackliter
-------- ------------------ --------------- ---------------
60000305 2842.97 2802.97 40.00
60000313 1199.98 1179.98 20.00
也就是按oilno分组了。。
select nodename from nodeinfor where nodeno='14000697'
这个有可能会是空值所以据我所知,可能要判断一下了。。多谢,,各位解决一下了。。
select ... sum(a.gowordnum) ... group by (a.oilno);
这样做的。是得到结果了,可这样会丢数据,因为当oilbackliter为空时可能就会丢一些数据了,我看了下我这的库是这种情况。。
gowordnum liter_total1
oilbackliter opedate
-------- ----------------------------------------- ---------------
--------------- ----------
14000697 1199.98 1179.98
20.00 2006/10/14
14000697 2842.97 2802.97
40.00 2006/10/14
14000697 3225.08 1979.81
100.01 2006/10/20
14000697 977.50 876.69
100.81 2006/10/20
14000697 2249.75 2128.39
121.36 2006/10/20
14000697 961.95 658.48
303.47 2006/10/20
可问题是oilbackliter为空的也有别的字段的值,也是我想要的。
这问题这长时间了,没人给解决下吧吗?
谢谢上面兄弟的解决。感谢。
select distinct a.oilno,…………