1.1查询account表中客户的姓名(fullname)、地址(address)和电话(phone),显示的列标题要求显示“姓名”“地址”“电话”
Select fullname as 姓名,address as 地址, phoneas 电话 from account;
1.2 查询lineitem表中商品号(itemid)和单价(unitprice),要求清除重复行
Select distinct itemid,unitprice from lineitem;
1.3 计算lineitem表中每条记录的商品金额
Select orderid,itemid,quantity * unitprice as 金额 from lineitem;
1.4 查询account表中客户的姓名(fullname)和性别(sex),要求性别为“男”时显示1,性别为女时显示0.
Select fullname,
Case when sex = ‘男’ then ‘1’、
When sex = ‘女’ then ‘0’
End as sex
From account;
1.5 查询product表中商品名(name)和档次。档次按单价(unitcost)划分,1000元一下显示为“低价商品”,1000元到2000元显示为“中档商品”,2000元及以上显示为“高档商品”
Select name,
Case