Chinaunix首页 | 论坛 | 博客
  • 博客访问: 388473
  • 博文数量: 99
  • 博客积分: 5134
  • 博客等级: 大校
  • 技术积分: 1607
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 09:31
文章分类

全部博文(99)

文章存档

2011年(48)

2010年(40)

2009年(10)

2008年(1)

分类:

2009-12-15 10:37:14

1.选择N行
    select * from user_tables where rownum<=10;
    select table_name from user_tables where rownum<=20 order by table_name;   升序
    select table_name from user_tables where rownum<=20 order by table_name desc;  降序

2.计算总和:
    select sum(column1) from table_name;
3.计算行数:
    select count (*) from table_name where column_name = xxx;
4.排序:
    select column1,avg(column2) from table_name group by column1 having avg(column2) > xxx;
select * from table_name1 where column1 like 'x%'
说明:like 必须和後面的'x%' 相呼应表示以 x为开头的字串。
区分大小写。

select * from table_name1 where column1 in ('xxx','yyy',..)
说明:in 後面接的是一个集合,表示column1 存在集合里面。

select * from table_name1 where column1 between xx and yy;
说明:between 表示 column1 的值介於 xx 和 yy 之间。

update table_name set column1='xxx' where conditoins;
delete from table_name where conditions;


a.如果是access数据库,则为:where mydate>#2000-01-01#
b. 如果是oracle数据库,则为:where mydate>cast('2000-01-01' as date) 或:where mydate>to_date('2000-01-01','yyyy-mm-dd') 在delphi中写成: thedate='2000-01-01'; query1.sql.add('select * from abc where mydate>cast('+''''+thedate+''''+' as date)');

推荐在oracle里面使用 如果比较日期时间型,则为: where mydatetime>to_date('2000-01-01 10:00:01','yyyy-mm-dd hh24:mi:ss')
阅读(602) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~