DELPHI技巧:InterBase使用方法总结计算机二级考试
文章作者 100test 发表时间 2009:05:13 17:43:35
来源 100Test.Com百考试题网
2009年下半年全国计算机等级考试你准备好了没?考计算机等级考试的朋友,2009年下半年全国计算机等级考试时间是2009年9月19日至23日。更多优质资料尽在百考试题论坛 百考试题在线题库
InterBase 语法:
1)创建视图
CREATE VIEW V_MEMCOSTORDER(
MEMBERID,NAME,ADDR,TEL,
AMTAR,SALOCC,AMTOCC,CHECKOUTTIME
)
AS
0select D.MEMBERID,D.NAME,D.ADDR,D.TEL, A.CHECKOUTTIME,
SUM(A.AMTAR) AS AMTAR,COUNT(*) AS SALOCC ,SUM(A.AMTAR)/COUNT(*) AS AMTOCC
from Table1 A
INNER JOIN Table2 D ON A.MEMBERID=D.MEMBERID
GROUP BY D.MEMBERID,D.NAME,D.ADDR,D.TEL,A.CHECKOUTTIME
2)AS字段在Order by 里面排序以及 选择N条记录
0select DSBM,SUM(NBYXCSY) as NBYXCSY from BOOKXSHZ where iYear=2002
and DSBM not in (0select CDSBM from BOOKTB)
group by DSBM
order by NBYXCSY DESC ROWS 1 to 5
执行结果:
DSBM NBYXCSY
===================== ========
G-055 87896.2
M-5 112056
D-009 264628.4
G-061 41588.9
F-067 222621.28
为什么NBYXCSY不排序呀?
正确写法如下:
0select DSBM,SUM(NBYXCSY) as NBYXCSY from BOOKXSHZ where iYear=2002
and DSBM not in (0select CDSBM from BOOKTB)
group by DSBM
order by 2 DESC Rows 1 to 5
Rows 1 to 5代表只显示前5条记录,此功能只在6.5以上版本中有效。
特别推荐:
2009年9月全国计算机等级考试时间及科目预告