sd744713350的gravatar头像
sd744713350 2018-05-09 21:50:47

sql语句如何实现如下的条件查询需求

求解sql语句

sql语句如何实现如下的条件查询需求

所有回答列表(5)
娱乐人的gravatar头像
娱乐人  LV3 2018年5月17日

SELECT SUM(Account) 
FROM account
WHERE State='00'

SELECT COUNT(property) 
FROM custinfo
WHERE Property = '2'

SELECT * 
FROM custinfo ,account 
WHERE custinfo.`CustId`=account.`CustId` AND Property='1' AND State='00'

SELECT SUM(Account)
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId`
GROUP BY property

SELECT *
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId`
GROUP BY property

SELECT custinfo.`CustId`,account.`CustName`,SUM(Account)
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId` AND custinfo.`Property`='1' 
GROUP BY custinfo.`CustId`
HAVING SUM(Account)>5000000

评论(1) 最佳答案
sunjiyun26的gravatar头像
sunjiyun26  LV9 2018年5月14日

这么多问题,3个牛币

zyname的gravatar头像
zyname  LV6 2018年5月28日

SELECT SUM(Account) 
FROM account
WHERE State='00'

SELECT COUNT(property) 
FROM custinfo
WHERE Property = '2'

SELECT * 
FROM custinfo ,account 
WHERE custinfo.`CustId`=account.`CustId` AND Property='1' AND State='00'

SELECT SUM(Account)
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId`
GROUP BY property

SELECT *
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId`
GROUP BY property

SELECT custinfo.`CustId`,account.`CustName`,SUM(Account)
FROM custinfo,account
WHERE custinfo.`CustId`=account.`CustId` AND custinfo.`Property`='1' 
GROUP BY custinfo.`CustId`
HAVING SUM(Account)>5000000

对不起_我是甲方卧底的gravatar头像
对不起_我是甲方卧底  LV2 2018年6月12日

这是在笔试?面试?

橙子1的gravatar头像
橙子1  LV6 2018年6月22日

快下班了,能写多少就多少吧!

1.select sum(amount) from account

2.select count(c.custid) from custinfo c left join account ac on c.sustid = ac.custid where c.property = '1' group by c.custid

3.select ac.* from custinfo c left join account ac on c.sustid = ac.custid where c.property = '2' and ac.state = '00'

4.select count(id),sum(amount) from account group by state

5.select ac.custid,ac.custname,sum(amount) from custinfo c left join account ac on c.sustid = ac.custid where c.property = '2' group by c.custid having sum(amount)>5000000

 

盲写的  不保证正确率

顺便说下,并不喜欢 from 的表 用 逗号链接~

笛卡尔乘积 表示驾驭不了~

顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友