当前位置: 首页 > 图文教程 > 数据库 > MSSQL > sql 多表连接查询

MSSQL
mssql 两种数据插入方式
mssql @@ERROR 使用
sqlserver 数据库日志备份和恢复步骤
SQL Server日志过大会影响查询结果
SQLserver 实现分组统计查询(按月、小时分组)
SQL语句查询是否为空 =null及null
对有insert触发器表取IDENTITY值时发现的问题
SQL SERVER 查询正在实行的SQL语句
sql 随机抽取几条数据的方法 推荐
sql 多条件组合查询,并根据指定类别找出所有最小子类别的SQL语句备忘
Java 实现连接sql server 2000
SQL Server 不存在或访问被拒绝(转)
分页查询 效率最高
sqlserver 系统存储过程 中文说明
sql 多表连接查询
SQL SERVER 自增列
丢失的数据忘记备份的处理方法[图文]
SqlServer 序号列的实现方法
MsSql 存储过程分页代码 [收集多篇]
SQLServer 数据库中如何保持数据一致性

MSSQL 中的 sql 多表连接查询


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 51 ::
收藏到网摘: n/a

sql 多表连接查询语句代码,大家可以参考下。 select * from (SELECT id,jihao, ht.hetongid, hetonghao, banshichu, zulindanwei, jiansheluduan, shebeijinchangriqi,hetongfangshi,
jine,yusuangongchengliang,(ht.jine/30)*(datediff(day,ht.shebeijinchangriqi,getdate())) as yusuanjine,yihuikuanjine,
((ht.jine/30)*(datediff(day,ht.shebeijinchangriqi,getdate()))-yihuikuanjine) as qiankuanjine,ht.shebeituichangriqi
FROM db_hetongguanli_y_g as ht left join select sum (gongchengliang) as yusuangongchengliang ,hetongid
from db_meirigongchengliang group by hetongid) as d on ht.hetongid=d.hetongid left
join(select sum(shijihuikuanjine) as yihuikuanjine,hetongid from db_huikuan group by hetongid) as a on ht.hetongid=a.hetongid ) as b
where b.hetongfangshi='月租' and b.hetongid=(select hetongid from db_shebeixinxi where jihao='" + this.DropDownList1.SelectedValue + "')";
==================================================================================================
select * from (select ht.id,ht.qiandingren,ht.hetongid,ht.banshichu,ht.jihao,ht.hetonghao,ht.zulindanwei,
ht.jiansheluduan,ht.qingqianriqi,ht.lumianshigongcailiao,ht.hetongfangshi,ht.jine,ht.hetongqiandingriqi,
ht.hetongjiesuanjine,ht.hetongjiesuanriqi,ht.shebeijinchangriqi,ht.shebeituichangriqi,ht.jiesuangongchengliang,
d.yifukuanjine, (ht.hetongjiesuanjine-d.yifukuanjine) as qiankuanjine,ht.kaipiaojine,ht.ranyoufei,ht.yunfei,
ht.qitafeiyong,ht.feiliaofei from db_hetongguanli_y_g as ht left join (select hetongid,sum(shijihuikuanjine) as yifukuanjine
from db_huikuan group by hetongid) as d on ht.hetongid=d.hetongid) as a
where a.hetongid=(select hetongid from db_shebeixinxi where jihao='5666')
go