postgre-sql语法
//客户端查询
public void pgsearchclient(HttpContext context, string starttime, string endtime, int page, int rows, string phone,string province)
{
endtime = Convert.ToDateTime(endtime).AddDays(1).ToString("yyyy-MM-dd");
string sql = "SELECT ";
sql += " CASE WHEN ffoi.city_id in(SELECT id from fc_city where fccc.p_id=0) then fccc.short_name when ffoi.city_id=0 then '全国' ELSE fcc.short_name end as province, ";
sql += " CASE WHEN ffoi.city_id in(SELECT id from fc_city where fccc.p_id=0) then fccc.short_name when ffoi.city_id=0 then '全国' ELSE fc.short_name end as city, ";
sql += " CASE WHEN ffoi.operators=0 THEN '电信' WHEN ffoi.operators=1 THEN '移动' WHEN ffoi.operators=2 THEN '联通' END as operatorsname,";
sql += " ffo.mobile,";
sql += " to_char(ffo.updatetime,'yyyy-MM-dd hh24:mi:ss') as updatetime";
sql += " ,ffoi.display_name";
sql += " ,ffoi.product_name";
sql += " ,ffoi.product_code,";
sql += " ffoi.tag_type";
sql += " ,ffoi.fee";
sql += " ,ffoi.flow_size";
sql += " ,ffoi.product_id";
sql += " ,ffoi.flow_type";
sql += " ,ffo.cash_fee";
sql += " ,ffo.app_code";
sql += " ,ffo.status";
sql += " ,'客户端' as channel";
sql += " ,ffoi.operators";
sql += " ,ffo.id as zongkuid";
sql += " ,ffo.order_no";
sql += " ,to_char(ffo.createtime,'yyyy-MM-dd hh24:mi:ss') as createtime";
sql += " ,ffo.unique_id";
sql += " ,to_char(ffo.success_time,'yyyy-MM-dd hh24:mi:ss') as success_time";
sql += " ,ffo.send_sms_time";
sql += " ,ffoi.city_id";
sql += " FROM fc_flow_order as ffo ";
sql += " LEFT JOIN fc_flow_order_item as ffoi on ffoi.order_id=ffo.id ";
sql += " LEFT JOIN fc_city as fc on ffoi.city_id=fc.id and fc.is_city=1 ";
sql += " LEFT JOIN fc_city as fcc on fcc.id=fc.p_id and fcc.depth=2 ";
sql += "LEFT JOIN fc_city as fccc on ffoi.city_id=fccc.id and fccc.p_id=0 where 1=1 ";
if (starttime != "")
{
sql += " and ffo.updatetime>='" + starttime + "'";
}
if (endtime != "")
{
sql += " and ffo.updatetime<='" + endtime + "'";
}
if (phone != "")
{
sql += " and ffo.mobile='" + phone + "'";
} if (province != "")
{
sql += " and fcc.short_name='" + province + "'";
}
DataSet ds = ExecuteQuery2(sql);
DataTable dt = ds.Tables[0];
int count = dt.Rows.Count;
DataSet ds2 = comh.SplitDataSet(ds, page, rows);
context.Session["clientpgsearchTable"] = dt;
string strJson = "{\"total\":" + count + ",\"rows\":" + Newtonsoft.Json.JsonConvert.SerializeObject(ds2.Tables[0]) + "}";//DataSet数据转化为Json数据
context.Response.Write(strJson);//返回给前台页面
context.Response.End();
}
public DataSet ExecuteQuery2(string StrText)
{
string StrConnection = ConfigurationManager.ConnectionStrings["sqlConnection5"].ConnectionString;
using (NpgsqlConnection conn = new NpgsqlConnection(StrConnection))
{
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand(StrText, conn);
NpgsqlDataAdapter NpgDa = new NpgsqlDataAdapter(cmd);
DataSet ds = new DataSet();
NpgDa.Fill(ds, "ds");
cmd.Parameters.Clear();
return ds;
}
}
postgre-sql语法的更多相关文章
- [数据库] SQL 语法之基础篇
一.什么是 SQL ? SQL 是 Structured Query Language(结构化查询语言)的缩写,是一种专门用来与数据库沟通的语言.与其他语言(如英语或 C.C++.Java 这样的编程 ...
- 值得注意的ibatis动态sql语法格式
一.Ibatis常用动态sql语法,简单粗暴用一例子 <select id="iBatisSelectList" parameterClass="java.util ...
- Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等)
Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等) 子查询 描述:查询订单数超过5的顾客信息 查询句法: var 子查询 = from c i ...
- SQL 语法总结
学了一个月的java,开始有入门的感觉.这段时间接触到了java的JDBC, 发现学习这部分的内容还是要有SQL的基础,于是花费了几天时间学习了一下SQL语法,并将其总结于下. 选择数据 SELECT ...
- SQL语法和运算符(一)
一个数据库通常包含一个或多个表.每个表由一个名字标识,表包含带有数据的记录(行). 一些最重要的SQL命令(SQL对大小写不敏感): 一.SQL语法 select:从数据库中提取数据 update:更 ...
- [转]MySQL 最基本的SQL语法/语句
MySQL 最基本的SQL语法/语句,使用mysql的朋友可以参考下. DDL-数据定义语言(Create,Alter,Drop,DECLARE) DML-数据操纵语言(Select,Delete ...
- SQL语法整理
SQL是Structured Query Language的缩写,中文全名为结构化查询语言,是一种用于数据存储,查询,更新和管理的关系数据库系统. SQL语法 创建表 create table tab ...
- ORACLE分页查询SQL语法——最高效的分页
--1:无ORDER BY排序的写法.(效率最高)--(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!) SELECT * FROM (SELECT ...
- [Android新手区] SQLite 操作详解--SQL语法
该文章完全摘自转自:北大青鸟[Android新手区] SQLite 操作详解--SQL语法 :http://home.bdqn.cn/thread-49363-1-1.html SQLite库可以解 ...
- 有没有好用的开源sql语法分析器? - 匿名用户的回答 - 知乎
有没有好用的开源sql语法分析器? - 匿名用户的回答 - 知乎 presto,hive,drill,calcite,sparksq
随机推荐
- 七、python沉淀之路--集合
一. 1.字符串转集合 s = 'hello' se = set(s) print(se) {'e', 'o', 'h', 'l'} 2.列表转集合 l1 = ['hello','python','n ...
- 微信小程序编写物流信息进度样式
做电商类型的小程序一定会碰到编写物流信息的时候,一般页面如下图 难点在于只有一条信息时候的页面样式 以及多条信息最后一条信息的页面样式 之前没做过这一块的东西,所以刚碰到的时候想了老半天orz.后来上 ...
- Surface Pro 4远程桌面分辨率问题
Surface Pro 4是非常收欢迎的笔记本电脑.但我们这些技术人员在使用中有一点非常不方便: Surface Pro 4的分辨率非常高,如果用Surface Pro 4远程桌面到远端的一台机器,因 ...
- linux下的时间
1.linux下时间管理机制: 在系统启动时,Linux操作系统将时间从CMOS中读到系统时间变量中,以后修改时间通过修改系统时间实现.为了保持系统时间与CMOS时间的一致性,Linux每隔11分钟会 ...
- HUD2102(基础bfs)
A计划 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- POJ3258(最大化最小值)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11155 Accepted: 4785 ...
- SQL 用;with 由所有的子节点查询到树结构中所有父节点
1.所有的子节点查询到树结构中所有父节点 RETURNS @Tree Table(PID )) as begin --DECLARE @ID VARCHAR() --SET @ID = ' ;with ...
- DevExpress TreeList GridView 样式设置
1.GridView 样式设置 this.gridViewUser.PaintStyleName = "Flat"; 2.TreeList 样式设置 this.treeListDe ...
- VMware安装操作系统(Operating System not found一个错误原因)
因为指定的IOS文件是多种操作系统的组合,如Win7(32位和64位完全版),那么安装的时候选择一个操作系统类型和ios文件的类型就匹配不上,所以出现这种错误.
- SPARC T4 RAID Setup (ZT)
http://www.confignotes.com/2013/09/sparc-t4-raid-setup/ How to configure a RAID volume with the inte ...