标签:时间表 表示 方法 to_char 关联表 rand pki 颜色 join
数据库中多表关联查询。
select c.CARCARDNUMBER as 车牌号码,‘蓝牌‘ as 车牌颜色,‘小型轿车‘ as 车辆类型,‘出租客运‘ as 使用性质,c.CARBRAND as 车辆品牌,c.CARVERSION as 车辆型号,c.ISDOUBLEFULE as 是否双燃料车,
fu.name as 燃料种类,c.REGISTERDATE as 注册日期,a.checktime as 最后一次检查时间,d.stationname as 检测站,m.name as 检测方法
from BAS_CARINFO c
inner join (select mas.* from INS_CHECKRESULTMAIN mas inner join (select carpkid,max(checktime) as checktime from INS_CHECKRESULTMAIN group by carpkid) ma on mas.carpkid=ma.carpkid and mas.checktime=ma.checktime) a on a.carpkid=c.pkid
INNER JOIN BAS_CHECKSTATION d on d.PKID=a.stationpkid
left join COD_CARDCOLOR e on e.code=c.carcardcolor
left join COD_CARMODE f on f.code=c.CARMODE
left join COD_CHECKMETHOD m on m.code=a.checkmethod
left join cod_FUELTYPE fu on fu.code=c.fueltype
where "TO_CHAR"(a.checktime,‘yyyy-mm-dd‘)>=‘2019-05-01‘ and "TO_CHAR"(a.checktime,‘yyyy-mm-dd‘)<=‘2019-11-01‘ and c.USEDQUALITY=‘33‘ and c.CARMODECODE=‘K33‘
order by STATIONNAME,checktime
select t.name 姓名,t.password from table t ; t表示替换字符,可以用t直接点出。姓名表示 索引头用姓名替代name. as这个可有可无
inner join left join 添加关联
to_date(‘2020-02-02‘,‘yyyy-mm-dd‘) 查询的时间表示方法
on 用来关联表中的字段对应另一张表中的字段
标签:时间表 表示 方法 to_char 关联表 rand pki 颜色 join
原文地址:https://www.cnblogs.com/bellwether/p/12625297.html