ITPub博客

首页 > 数据库 > Oracle > SQL基础(四)数据查询

SQL基础(四)数据查询

原创 Oracle 作者:cxck 时间:2007-03-20 11:12:35 0 删除 编辑
数据查询 select、where、group by、order by[@more@]

■select
查询表或者视图的数据。
【例】select * from cxck.t产品
where 产品号 = 'a001'
查询where 指定的产品号等于a001的所有列的数据。

【例】select 产品号, 出库数 from cxck.t产品
where 产品号 = 'a001'
查询产品号为 a001 的产品号和出库数。

【例】select 产品号, 出库数 from cxck.t产品
where 产品号 >= 'a001' and 产品号 <= 'a999'
order by 产品号
查询产品号在a001 ~ a999 之间的产品号和出库数,并按 order by 指定的产品号升序排列。
order by 产品号 desc 时,降序排列。

【例】select 产品号, sum(订货数) from cxck.v订货1
where 产品号 >= 'a001' and 产品号 <= 'a999'
group by 产品号
order by 产品号
v订货1 的产品号在a001 ~ a999 之间订货数按 group by 指定的产品号分组合计,并按产品号排序。

Oracle 可以通过from cxck.v订货1 v订货1 使用表的别名。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/174388/viewspace-905935/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    38
  • 访问量
    74701