写一个SQL语句。 - MS-SQL Server / 应用实例
表:T1数据如下
a 1
a 2
a 3
b 1
b 2
表 t2数据如下
a 1
a 2
a 3
a 4
b 1
b 2
b 3
想从t2中得出
a 4
b 3
的SQL语句。
select * from tb2
intersect
select * from tb1
SQL code:
select * from tb2
except
select * from tb1
SELECT * from TB2 T WHERE NOT EXISTS(SELECT 1 from TB1 WHERE A=T.A AND B=T.B)
SQL code:
--------------------SQL Server数据格式化工具-------------------
---------------------------------------------------------------
-- DESIGNER :happycell188(喜喜)
-- QQ :584738179
-- Development Tool :Microsoft Visual C++ 6.0 C Language
-- FUNCTION :CONVERT DATA TO T-SQL
---------------------------------------------------------------
-- Microsoft SQL Server 2005
-- Developer Edition on Microsoft Windows XP [版本 5.1.2600]
---------------------------------------------------------------
---------------------------------------------------------------
use test
go
if object_id('test.dbo.t1') is not null drop table t1
-- 创建数据表
create table t1
(
id char(2),
num int
)
go
--插入测试数据
insert into t1 select 'a',1
union all select 'a',2
相关问答:
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
请教高手:
以下是数据库中的三条记录,英文为字段名称
id planname TaskBeginTime Status
329 2010年03 ......
查询学生平均成绩及其名次
SELECT 1+(SELECT COUNT( distinct 平均成绩)
from (SELECT S#,AVG(score) AS 平均成绩
from SC&n ......