查询一小时
select concat(to_char(sysdate,'yyyy-mm-dd ')||(to_char(sysdate,'hh24')-1),':00:00') start_time,concat(to_char(sysdate,'yyyy-mm-dd hh24'),':00:00') end_time from dual
查询前一天
select to_char(sysdate-1,'yyyy-mm-dd ')||'00:00:00' start_time,to_char(sysdate-1,'yyyy-mm-dd ')||'23:59:59' end_time from dual
查询前一个月
select concat(to_char(sysdate,'yyyy')||to_char(add_months(sysdate,-1), '-MM-'),'01 00:00:00')start_time,
concat(to_char(sysdate,'yyyy')||to_char(add_months(sysdate,-1), '-MM-')||to_char(LAST_DAY(sysdate),'dd '),'23:59:59') end_time from dual
查询前一年
select extract(year from sysdate)-1||'-01-01 00:00:00' start_time,concat(extract(year from sysdate)-1||'-12-'||to_char(LAST_DAY(sysdate),'dd '),'23:59:59') end_time from dual
来源:
zhangketuan
查询一小时 select concat(to_char(sysdate,'yyyy-mm-dd ')||(to_char(sysdate,'hh24')-1),':00:00') start_time,concat(to_char(sysdate,'yyyy-mm-dd hh24'),':00:00') end_time from dual 结果: 查询前一天 select to_ch...
sql语句:(主表A的id=明细表B的mainid)
select A.gzm,B.rq from A,B where A.id=B.mainid and trunc(to_date(B.rq,'yyyy-mm-dd'))>=trunc(sysdate)
可以使用cx_
Oracle
库来实现这一功能,它提供了一种利用Python和
Oracle
数据
库之间的连接的方法,可以让你使用Python来
查询
Oracle
数据
库并获取
查询
结果。可以使用以下示例代码来实现:import cx_
Oracle
connection = cx_
Oracle
.connect("username", "password", "host")cursor = connection.cursor()query = "SELECT column1, column2 FROM table1"cursor.execute(query)rows = cursor.fetchall()for row in rows:
print(row[0], row[1])cursor.close()
connection.close()