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 ...
随机推荐
- 二层协议--STP协议总结
生成树协议的技术实现与配置注意点 一.stp协议的用途 二.stp协议的运行机制 三.stp协议规范
- Windows中几个内存相当的指标
以下几个内存大小相当: IS:虚拟内存任务管理器:提交内存进程对象上的:PrivateMemorySize64,性能计数器:Process\Private Bytes
- Network-Emulator Network-Emulator-Toolkit网络模拟器使用详细介绍
Network-Emulator-Toolkit网络模拟器使用详细介绍 by:授客 QQ:1033553122 原理介绍 图1 如上图,一个ADSL用户通过modem连接到网络,通过网络应用如IE,M ...
- PullToRefreshGridView上拉刷新,下拉加载
PullToRefreshGridView上拉刷新,下拉加载 布局: <?xml version="1.0" encoding="utf-8"?> ...
- Android View体系(八)从源码解析View的layout和draw流程
前言 上一篇文章我们讲了View的measure的流程,接下来我们讲下View的layout和draw流程,如果你理解了View的measure的流程,那这篇文章自然就不在话下了. 1.View的la ...
- python格式化字符串format函数
1. format可以接受无限个的参数,位置可以不按顺序: In [1]: "{} {}".format("hello","world") ...
- .net core HttpContext(Http上下文)
在.NET Core中,只有Controller才能直接使用 HttpContext ,其他地方需要通过HttpContextAccessor来访问
- Django电商项目---完成登录验证和用户中心(个人信息)day3
登录验证的实现 背景说明: 用户在商品界面选择商品后,在点击购物车或者结算订单之前 需要完成用户的登录验证,这里用装饰器来完成 创建装饰器类: df_user/user_decorator.py ...
- table表格(笔记)
<table class="table table-hover2 pick_carTable"> <thead> <tr class="bl ...
- win7系统开机后电脑桌面背景变黑的解决方法
自从微软放弃了对win7系统的维护更新,一些BUG也就慢慢出现了,最近用户反映,开机后电脑桌面背景变黑,即使重新换了桌面背景,还是会出现这种情况.下面小编就来告诉大家怎样解决这一问题. 1.点击开始菜 ...