select coalesce( sum(duration) , 0)--若sum(duration)返回值为空,则为其赋值0
select to_date('2013-12-20','YYYY-MM-DD') --字符串转化为date类型
select (date '2013-10-28 01:00' - interval '50 minutes'|| ' ')--字符串的拼接
select to_char( CURRENT_DATE, 'YYYY-MM-DD')--时间类型转为为字符串
SELECT EXTRACT(HOUR FROM timestamp '2013-10-28 01:00' - interval '1 days' ) --获取一天前小时值
SELECT EXTRACT(HOUR FROM CURRENT_TIME - interval '3 hours' ) --获取三个小时前的小时
v_day_start := select to_char( CURRENT_Date, 'YYYY-MM-DD')--赋值加类型转换
select date_part('epoch', timestamp '2013-11-28 11:00'- timestamp '2013-11-28 01:30' ); --将时间差转变为秒数
select sum(duration) from engine_test where state_start >='2013-12-12 12:30' and state_stop <'2013-12-12 14:30' and station='GCIC_TC01'
select date_part('epoch', timestamp '2013-11-28 01:00'- timestamp '2013-11-27 17:30' ); --把时间差转化为秒
select 23+23 --数值计算
v_runtime := v_starttime_interval + v_runningtime + v_endtime_interval --存储过程中的赋值加减操作
select state_stop - '2013-12-12 12:30' from engine_test
where state_start <= '2013-12-12 12:30' and state_stop > '2013-12-12 12:30'
and type = 1 and station='GCIC_' || 'TC02';--时间类型的计算
select coalesce( sum(duration) , 0) from engine_test where station = 'GCIC_' || i_station --根据传入的参数i_station进行拼接字符串拼接,然后作为查询条件来使用
and createdon >= '2013-12-12 10:30'
and createdon < '2013-12-12 12:30';
postgreSQL常用函数
最新推荐文章于 2024-07-08 08:49:34 发布