create table sale
( 货号 int not null,
品名 char(20) not null,
数量 int not null,
单价 char(20) not null,
总价 as 数量*单价, --计算列
primary key(货号)
)
go
( 货号 int not null,
品名 char(20) not null,
数量 int not null,
单价 char(20) not null,
总价 as 数量*单价, --计算列
primary key(货号)
)
go
( 货号 int not null,
品名 char(20) not null,
数量 int not null,
单价 money not null, --money数据类型
总价 as 数量*单价, --计算列
primary key(货号)
)
go
create table goods
( 编号 int not null,
品名 char(20) not null,
库存量 int not null,
进价 money not null,
售价 money not null,
供货商编号 int not null,
primary key (编号)
)--对于数值型数据字段,不需要用单引号
insert into goods values('1','康师傅橙汁',56,3.7,5.6,1);
insert into goods(编号, 品名,库存量,进价,售价,供应商编号) values('1','康师傅橙汁',56,3.7,5.6,1);
values(
'1',
'康师傅橙汁',
20, --int
3.7, --money
)--如果总价定义为计算列,追加后自动计算总价
我现在想计算出总价这一属性的和,怎么做呢?
select sum(总价) from sale;
可以吗?
得到的值我又能如何保存呢?
我在Delphi中
begin
sqlStr:='select sum(总价) from sale';
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add(sqlStr);
Open;
end;
if recordcount<1 then Edit5.Text:='';
end;
我不知道从哪里得到查询的值。
如果可以,能留下你的QQ吗?
我的QQ:66574049