1、指定列:

select Sno,Sname

from Student;

2、查询经过计算的值:

select Sname,’year of birth:’,2008-Sage,Sdept

from student;

3、去除取值重复的行:

select distinct Sno

from student;

4、满足条件的元组:

select Sname,Sage

from Student

where Sdept =’CS’ AND Sage<=19;

5、确定范围,集合

select Sname

from Student

where Sage BETWEEN 18 AND 20;

select Sname

from Student

where Sdept IN (‘CS’,'MA’);

6、匹配查询

select *

from Student

where Sno LIKE ‘100%’;

7、Order By子句

select Sno,Grade

from SC

where Cno =’2′

ORDER BY Grade DESC;

//DESC是降序,缺省为升序;

8、聚集函数:

select COUNT(Sno)

from Student;

select AVG/MAX/MIN(Grade)

from SC

where Cno =’1′;

9、Group By子句:

select Cno,COUNT(Cno)

from SC

GROUP BY Cno;

Tags: , ,

Related posts

Tags: ,,.
Home

No Comments Now!

Be the first to comment on this entry.

Leave a comment

Name(required)
Mail (required),(will not be published)
Website(recommended)

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs must be fully qualified (eg: http://hanghang.name),and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.