--Currency 字段存储的是值0、1、2,0的时候显示为'人民币' ,1的时候显示为'美元' ,2的时候显示为'欧元'
CASE dbo.ProductINFO.Currency WHEN 0 THEN '人民币' WHEN 1 THEN '美元' WHEN 2 THEN '欧元' END AS PRICE_NEW
CASE dbo.ProductINFO.Currency WHEN 0 THEN '人民币' WHEN 1 THEN '美元' WHEN 2 THEN '欧元' END AS PRICE_NEW
dbo.ProductINFO.Currency =1那么结果就是 '100.12美元'
dbo.ProductINFO.ProductNum, -
dbo.ProductINFO.ProductName,
dbo.ProductINFO.ProductSortNum,
dbo.ProSortINFO.ProSortName,
dbo.ProductINFO.ProductFactoryNum,
dbo.FactoryINFO.FactoryName,
dbo.ProductINFO.ProductType,
dbo.ProductINFO.ProductPrice,
dbo.ProductINFO.Currency,
dbo.ProductINFO.Re, --以上为显示列
str(dbo.ProductINFO.ProductPrice, 5, 2) --保留长度为7,2位小数位的"字符"
+ CASE dbo.ProductINFO.Currency
WHEN 0 THEN '人民币' --当Currency为0时显示"人民币"
WHEN 1 THEN '美元' --当Currency为1时显示"美元"
WHEN 2 THEN '欧元' END --当Currency为2时显示"欧元"
AS PRICE_NEW --显示别名
FROM
dbo.ProductINFO
LEFT OUTER JOIN --左连以ProductINFO为基础FactoryINFO的FactoryNum在ProductINFO不存在时显示为null
dbo.FactoryINFO ON dbo.ProductINFO.ProductFactoryNum = dbo.FactoryINFO.FactoryNum
LEFT OUTER JOIN --左连以ProductINFO为基础FactoryINFO的ProSortNum在ProductINFO不存在时显示为null
dbo.ProSortINFO ON dbo.ProductINFO.ProductSortNum = dbo.ProSortINFO.ProSortNum
str(dbo.ProductINFO.ProductPrice, 5, 2) --将ProductPrice变为保留2位小数,总长为5位(包括小数点、空格、正负号等)的字符串--examples:
select str(132.788,5,2) -- 132.8
select str(11132.788,5,2) -- 11133 从左往右取
select str(-1132.788,5,2) -- -1133
select str(111111132.788,5,2) -- ***** 整数部分超5位则显示5个星
左外连接(左连接):结果集几包括连接表的匹配行,也包括左连接表的所有行。
SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
B:right outer join:
右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。
C:full outer join:
全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。 还是看看帮助吧