惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
T
Tenable Blog
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
Simon Willison's Weblog
Simon Willison's Weblog
The Register - Security
The Register - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
H
Help Net Security
T
Threat Research - Cisco Blogs
D
DataBreaches.Net
S
Schneier on Security
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
P
Privacy International News Feed
S
Secure Thoughts
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
C
Cybersecurity and Infrastructure Security Agency CISA
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
博客园 - Franky
T
Tor Project blog
G
GRAHAM CLULEY
博客园 - 【当耐特】
Jina AI
Jina AI
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
About on SuperTechFans
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - lrary

JavaScript经典技巧 - lrary - 博客园 动态添加ASP.NET控件并绑定处理事件一例 - lrary - 博客园 脚本收藏 - lrary - 博客园 一些sql语句的详细解释[转] 特殊的DataGrid的绑定 - lrary - 博客园 纯脚本搞掂DataGrid表表头不动,表身滚动。(转摘) - lrary - 博客园 检验密码强度的JS类 - lrary - 博客园 数据库设计规范 V2.0 SQL语句特---殊统计(1) DataGrid 多行 DataGrid怎么产生一个分类的题头 AJAX 在.net的应用 Asp.NET程序中常用的三十三种代码 检测含有中文字符串的实际长度 根据区位得到汉字拼音首字母(c#) 认识ASP.NET配置文件Web.config Asp.net(C#)实现验证码功能 给Repeater、Datalist和Datagrid增加自动编号列 查找和统计页面上控件
sql怎么使用外连接
lrary · 2006-05-08 · via 博客园 - lrary

表3的姓名中应该包括所有出现在表1和表2姓名中的记录,如果某人在表1中没出现,则相当于创收为0;同样如果某人在表2中没出现,则相当于花费为0.
再举例Table1
姓名    创收
A      2000
C       300
A       200
Table2
姓名    花费
A        400
B         20
D        200
现在想得到一个综合结果,如下
姓名    创收    花费
A      2200    400
B         0     20
C       300      0
D         0    200

select isnull(a.姓名,b.姓名) as 姓名,a.创收,b.花费
from
  ( select table1.姓名,sum(table1.创收) 创收
    from table1
    group by table1.姓名
  ) as a
full outer join
(
  select table2.姓名,sum(table2.花费) 花费
  from table2
  group by table2.姓名
) as b
on a.姓名=b.姓名

(或者第一行为)
select isnull(a.姓名,b.姓名) as 姓名,isnull(a.创收,0) as 创收,isnull(b.花费,0) as 花费
否则有些查询出来的创收或花费为 NULL ,也许你需要他们为 0.