易截截图软件、单文件、免安装、纯绿色、仅160KB

测试一下自己的SQL水平

 
create table Student(Sname varchar(10),Ssex varchar(5),Sage int,S# int)
insert into Student
select '夏亮','男','21','1004'
select '成平','男','20','1001' union all
select '王波','男','19','1002' union all
select '突然','女','19','1003'
 
create table Course(C# varchar(10),Cname varchar(10),T# varchar(10))
insert into Course
select '006','化学','C06' union all
select '005','数学','C06' union all
select '004','地理','C05' union all
select '001','自然','C02' union all
select '002','社会','C01' union all
select '003','心理','C03'
 
 
IF EXISTS (SELECT 1 from SC)
    DROP TABLE SC
GO
create table SC(S# int,C# varchar(10),score int)
insert into SC
select '1004','002',13 union all
select '1004','004',13 union all
select '1004','005',13 union all
select '1004','006',13 union all
select '1004','001',13 union all
select '1004','003',35 union all
select '1003','002',95 union all
select '1003','001',55 union all
select '1001','006',55 union all
select '1001','005',100 union all
select '1001','001',100 union all
select '1002','001',null union all
select '1001','002',90 union all
select '1003','003',68
 
create table Teacher(T# varchar(10),Tname varchar(10))
insert into Teacher
select 'C04','天里浩'union all
select 'C05','天任浩'union all
select 'C03','立小丽'union all
select 'C02','朱列夫'union all
select 'C01','天任浩'union all
select 'C04','天里浩'union all
select 'C06','叶平'
 
select * from Course
select * from SC
select * from student
 
--Student(S#,Sname,Sage,Ssex) 学生表
--Course(C#,Cname,T#) 课程表
--SC(S#,C#,score) 成绩表
--Teacher(T#,Tname) 教师表
 
--问题:
--1、查询“”课程比“”课程成绩高的所有学生的学号:
select distinct S# from SC as sc where
(select score from sc as sc1 where c#='001' and sc1.s#=sc.s#)>
(select score from sc as sc2 where c#='002' and sc2.s#=sc.s#)
 
select S# from SC s where C#='001' and  score


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

SQL 学习笔记之索引

----use pubs-sales
-----创建索引
create index index_name
on authors(au_lname)
--创建索引后表中所有的数据跟之前没有区别
select * from authors
--单独查索引列
select au_lname from authors
--强制使用非簇集索引
select * from  authors with(index(index_name))
--多字段非簇集索引
create inde ......

巧用SQL中的WITH(树型结构数据的查询)

如果表中存放的数据是树形结构,当知道某一个节点的值时,同时想取得它所有子节点的数据。
表结构:
        
         
 表中存放的是部门组织结构, BMN_CD部门,SSK_KAISO_LV是阶层,BMN_MKJ部门名称,JOI_KAISO_LV上 ......

安装Oracle 10g inistant client后是PL/SQL出现乱码

想使用PL/SQL开发工具,但不想安装那个几百兆的oracle客户端,于是安装了oracle 10g inistant client,40多M吧。
安装后PL/SQL可以用了,但是查询出记录里面的中文却是乱码。折腾了好久才找出解决方法:
设置环境变量:NLS_LANG,值为Oracle数据库设置的字符集,在我的系统里面设置是:SIMPLIFIED CHINESE_CHINA.ZHS16GBK ......

SQL Server Compact不同版本的安装包(转)

2010-01-13 23:22
摘要:SQL Server Compact的安装包由三部分功能组成,并且区分CPU平台和操作系统平台,初学者往往不知道如何去区分它们。本文将对SQL Server Compact的安装包进行介绍,让你知道如何区分和选择它们。
如果你是使用Visual Studio 2005/2008开发.NET Compact Framework应用程序,并在程序中用到了SQL Serv ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号