【发布时间】:2014-03-12 07:18:23
【问题描述】:
我有一张表格,列有日期、系统、硬度、电导率、tankno。
日期系统 cond hard tankno 2014-01-04 HT 55.67 2.68 1 2014-01-05 HT 64.67 3.1 2 2014-01-10 HT 54.77 2.44 1 2014-01-10 HT 66.3 3.47 2 2014-01-18 HT 55.63 2.38 1 2014-01-18 HT 65.9 1.44 2 2014-01-24 HT 53.1 1.76 2 2014-01-28 HT 64.53 2.1 1我想要这样的报告
日期系统 Tank 1 cond Tank1 Hard Tank 2 cond Tank 2hard 2014-01-04 HT 55.67 2.68 NULL NULL 2014-01-05 HT NULL NULL 64.67 3.1 2014-01-10 HT 54.77 2.44 66.3 3.47 2014-01-18 HT 55.63 2.38 65.9 1.44 2014-01-24 HT NULL NULL 53.1 1.76 2014-01-28 HT 64.53 2.1 NULL NULL我正在使用这个 sql:
select t1.date, t1.cond as tk1cond, t1.hard as tk1hard,
t2.cond as tk2cond, t2.hard as tk2hard
from systemvalue t1 left join systemavalue t2
on t1.date=t2.date
and t2.tankno='2'
and t2.system='HT'
and month(t2.date)='01'
and year(t2.date)='2014'
where t1.tankno='1' and t1.system='HT'
and month(t1.date)='01'
and year(t1.date)='2014'
但此返回数据与 tankno 1 值可用的日期有关,如下所示:
日期系统 Tank 1 cond Tank1 Hard Tank 2 cond Tank 2hard 2014-01-04 HT 55.67 2.68 NULL NULL 2014-01-10 HT 54.77 2.44 66.3 3.47 2014-01-18 HT 55.63 2.38 65.9 1.44 2014-01-28 HT 64.53 2.1 NULL NULL如何修改sql以获取所有日期的数据
我想要日期列中的所有日期,并将其连接到所有 tank 1 vlaues 和 tank 2 值
【问题讨论】: