python init 方法 与 sql语句当前时间对比
def init(self,cr):
tools.sql.drop_view_if_exists(cr, 'custrom_product_infomation_report')
cr.execute("""
create or replace view custrom_product_infomation_report as (
select t0.id,t0.hpartner_id as hpartner_id, t0.khwl_code as khwl_code,t1.product_tmpl_id as productn,
t3.pname,t3.material,t3.spec,
t4.id as name_uom, t5.price as custo_price,t0.product_meno as product_meno ,t0.meno as meno,t5.date_from,t5.date_to
from product_custo_info t0
LEFT JOIN product_product t1 on t0.product_tmpl_id=t1.product_tmpl_id
LEFT JOIN product_template t3 on t3.id=t1.product_tmpl_id
LEFT JOIN res_partner t2 on t2.id=t0.hpartner_id
LEFT JOIN product_uom t4 on t3.uom_id=t4.id
left join partner_product_price t5 on t5.ppp_line_id=t0.id )
""") sql语句当该前时间对比: select * from (select t1.id,t0.product_meno,
t0.hpartner_id,t0.khwl_code ,t0.name_uom,t0.custo_price
,t0.product_meno,t0.meno,t2.pname ,t0.date_from,t0.date_to
from cust_product_info_report t0
LEFT JOIN product_product t1 on t1.product_tmpl_id=t0.productn
LEFT JOIN product_template t2 on t1.product_tmpl_id=t2.id
where (now()>=t0.date_from and now()<=t0.date_to) or (t0.date_from is null and t0.date_to is null ) or
(t0.date_from is null and (now()<=t0.date_to)) or (t0.date_to is null and (now()>=t0.date_from))
)
as p where hpartner_id='16404'
order by pname sql 中 : case ........when........... then.......
else....... end 方法: case tt3.send_invoice_type WHEN '1' then '汽车零担' WHEN '2' then '苏通快运'
WHEN '3' then '顺丰速运' WHEN '4' then '德邦快递' WHEN '5' then '优速快递'
WHEN '6' then '佳吉物流' WHEN '7' then '中通物流' WHEN '8' then '下午车'
else '' end 发运方式,
python init 方法 与 sql语句当前时间对比的更多相关文章
- SQL语句更新时间字段的年份、月份、天数、时、分、秒
SQL语句更新时间字段的年份.月份.天数.时.分.秒 --修改d表日期字段的年份update dset birth=STUFF(convert(nvarchar(23),birth,120),1,4, ...
- ACCESS与MSSQL比较:SQL语句关于时间格式使用的注意点
ACCESS与MSSQL比较:SQL语句关于时间字符串的使用:ACCESS数据库使用 # 来控制时间格式字符串:mssql数据库使用单引号 ' 来控制时间格式字符串.例: ACCESS版本:UPDAT ...
- 自己写的Python数据库连接类和sql语句拼接方法
这个工具类十分简单和简洁. sql拼接方法 # encoding=utf-8 from django.http import HttpResponse from anyjson import seri ...
- 查询sql语句所花时间
--1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的: declare @begin_date datetime declare @e ...
- 优化数据库的方法及SQL语句优化的原则
优化数据库的方法: 1.关键字段建立索引. 2.使用存储过程,它使SQL变得更加灵活和高效. 3.备份数据库和清除垃圾数据. 4.SQL语句语法的优化.(可以用Sybase的SQL Expert,可惜 ...
- SQL SERVER 查看SQL语句IO,时间,索引消耗
1.查看SQL语句IO消耗 set statistics io on select * from dbo.jx_order where order_time>'2011-04-12 12 ...
- mysql 修改表名的方法:sql语句
在使用mysql时,经常遇到表名不符合规范或标准,但是表里已经有大量的数据了,如何保留数据,只更改表名呢? 可以通过建一个相同的表结构的表,把原来的数据导入到新表中,但是这样视乎很麻烦. 能否简单使用 ...
- 如何在python文件中测试sql语句
在manage.py的同级目录下新建一个run.py import os if __name__ == '__main__': #加载Django项目的配置信息 os.environ.setdefau ...
- SQL语句获取时间的方法
1. 当前系统日期.时间select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值例如:向日期加上2天select dateadd(day ...
随机推荐
- 洛谷P3987 我永远喜欢珂朵莉~(set 树状数组)
题意 题目链接 Sol 不会卡常,自愧不如.下面的代码只有66分.我实在懒得手写平衡树了.. 思路比较直观:拿个set维护每个数出现的位置,再写个线段树维护区间和 #include<bits/s ...
- Spring Boot MyBatis配置多种数据库
mybatis-config.xml是支持配置多种数据库的,本文将介绍在Spring Boot中使用配置类来配置. 1. 配置application.yml # mybatis配置 mybatis: ...
- 小结:ES7——async和await初识
一.async async其实是ES7才有有的关键字,async的意思是异步,顾名思义是有关异步的操作 async用于声明一个函数是异步的. 通常情况下async.await都是跟随promise一起 ...
- Chrome浏览器跨域
配置新版Chrome浏览器跨域,需要创建用户数据文件夹,在其中保存浏览器的缓存.历史记录.收藏夹等数据. Windows系统Chrome跨域 1 下载Chrome 64位绿色版,解压缩,并在桌面创建快 ...
- loadrunner 运行场景-场景运行原理
运行场景-场景运行原理 by:授客 QQ:1033553122 运行原理 1 Remote Agent Dispatcher(Process) 运行Controller在负载机上开启应用程序. 2 ...
- Universal-ImageLoader,Picasso,Fresco,Glide对比
Universal-ImageLoader:(估计由于HttpClient被Google放弃,作者就放弃维护这个框架)优点:1.支持下载进度监听2.可以在 View 滚动中暂停图片加载,通过 Paus ...
- recovery 根据@/cache/recovery/block.map描述从data分区升级
随着android版本的更新,系统固件的大小也越来越大,升级包也越来越大,cache分区已经不够存储update.zip了,所以应用把update.zip下载到data分区,默认情况下data分区是可 ...
- Python数据清洗基本流程
# -*- coding: utf-8 -*-"""Created on Wed Jul 4 18:40:55 2018 @author: zhen"" ...
- [20171113]修改表结构删除列相关问题.txt
[20171113]修改表结构删除列相关问题.txt --//维护表结构删除字段一般都是先ALTER TABLE <table_name> SET UNUSED (<column_n ...
- iframe在iphone中滚动条无效
在iphone(ios11)中(其他苹果设备未尝试),不论是在微信的浏览器中,还是在其他浏览器中,iframe的滚动条怎么设置都没有效果,页面内容都无法进行滚动; 解决方法: 将iframe包裹在di ...