有两个表如下:
cusomer:
cust_name, char类型, 客户名
cust_date, char类型, 订单日及期格式(yyyy/MM/DD)
acount, int类型, 订单金额
rand:
cust_name, char类型, 客户名
rank, int类型, 客户等级
====================================================================
1. 查询2011年3份所有客户的订单总额
2. 查询2011年3份订单总额大于0并且第一个字为 "东 "的客户名称
3. 查询2011年3份份有订单并且客户等级大于2的客户
答案
1select sum(account) from customer where cust_date between '2011-03-01' and '2011-03-31'
2 select cust_name from
(select cust_name,sum(account) as sumAccount from customer where cust_date between '2011-03-01' and '2011-03-31' group by cust_name ) as A where cust_name like '东%' and sumAccount>0
3 select * from customer as c inner join rank as r where c.cust_name=r.cust_name and r.rank>2
以customer表为主,加上rank表中的满足条件的
13762127062
-------------------------------------
4.有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条sql语句查询出这三条记录并按以下条件显示出来(并写出您的思路):
大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。
显示格式:
语文 数学 英语
及格 优秀 不及格
。。。。。。。。。