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

MSSQL
SQL Server:SQL Server Maintenance Plan Wizard
SQL Server:SQL mai的配置和使用,你有所研究吗?
SQLServer:数据库的定时作业设置(经典)
SQL Server:小编浅谈SQL全文本检索方法
SQL Server:小编经验谈设计数据库表和字段
SQL Server:小编浅谈数据库完整性之约束
SQL Server:容易忽视的动态约束
SQL Server:时态数据库的时间间隔
SQL Server:浅谈数据库的安全性
SQL Server:不得不看的数据库设计技巧(看了终身受益)
SQL Server:数据库中的快照
SQL Server:数据库管理中关系代数的语法
SQL Server:关系代数中的语义
验证SQL保留字
精妙的SQL语句
SQL Server 数据库管理常用的SQL和T-SQL语句
SQL SERVER 与ACCESS、EXCEL的数据转换
SQL SERVER的数据类型
未公开的SQL Server口令的加密函数
SQl 语句(常见)

MSSQL 中的 sql 多表连接查询


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 33 ::
收藏到网摘: 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