日期:2014-05-17 浏览次数:20817 次
--创建数据开始
if(object_id('a') is not null) drop table a
go
create table a
(
material varchar(4),
length decimal(5,1),
width decimal(5,1)
)
go
insert into a
select 'A001',102,499 union all
select 'A003',1023,39 union all
select 'A001-A',2.2,32
go
--创建数据结束
--语句
select material as '品名',length as'长度',width as '宽度'
,cast(length as varchar)+'*'+cast(width as varchar) as '面积'
,width*length as '面积值'
from a
--结果展示
/*
品名 长度 宽度 面积 面积值
---- --------------------------------------- --------------------------------------- ------------------------- ---------------------------------------
A001 102.0 499.0 102.0*499.0 50898.00
A003 1023.0 39.0 1023.0*39.0 &