请你作为数据库老师做一下下面这个题目,T-SQL语句,对“bankcard”数据库完成下列查询。 (1)查询账号为41254280033512010000的账户的交易信息 (2)查询银行卡有哪些种类,只显示种类列,过滤掉重复行。 (3)查询身份证号为133***198708150101的储户的基本信息和其所有账户的信息。 (4)查询身份证号为133***198708150101的储户的总存款余额。 (5)求每个储户的账户个数和总存款余额,要求包括身份证号和姓名。 (6)查询总存款余额最多的储户信息。 (7)查询总存款余额超过10000的储户信息。 (8)查询有效期在一个月以内的账户及相应的储户信息。 (9)查询账号为43674280033512090000的账户2016年8月的总收入。 (10)查询所有账号以4367开头的账户的信息,并按余额降序排列。 (11)查询没有信用卡的储户的信息。 (12)查询所有VIP储户的总存款余额。 (13)将余额少于500的非VIP储户的账户的余额减10
时间: 2023-05-22 22:06:12 浏览: 581
1. SELECT * FROM bankcard WHERE account_number=41254280033512010000;
2. SELECT DISTINCT card_type FROM bankcard;
3. SELECT * FROM customer JOIN account ON customer.id_number=account.id_number WHERE customer.id_number LIKE '133___198708150101';
4. SELECT SUM(balance) FROM account WHERE id_number LIKE '133___198708150101';
5. SELECT customer.id_number, customer.name, COUNT(account.account_number), SUM(account.balance) FROM customer JOIN account ON customer.id_number=account.id_number GROUP BY customer.id_number, customer.name;
6. SELECT customer.id_number, customer.name, SUM(account.balance) AS total_balance FROM customer JOIN account ON customer.id_number=account.id_number GROUP BY customer.id_number, customer.name ORDER BY total_balance DESC LIMIT 1;
7. SELECT customer.id_number, customer.name, SUM(account.balance) AS total_balance FROM customer JOIN account ON customer.id_number=account.id_number GROUP BY customer.id_number, customer.name HAVING total_balance > 10000;
8. SELECT * FROM account JOIN customer ON account.id_number=customer.id_number WHERE DATEDIFF(month, GETDATE(), account.expiration_date) < 1;
9. SELECT SUM(amount) FROM transaction WHERE account_number=43674280033512090000 AND YEAR(transaction_date)=2016 AND MONTH(transaction_date)=8;
10. SELECT * FROM account WHERE account_number LIKE '4367%' ORDER BY balance DESC;
11. SELECT * FROM customer WHERE id_number NOT IN (SELECT id_number FROM credit_card);
12. SELECT SUM(account.balance) FROM customer JOIN account ON customer.id_number=account.id_number WHERE customer.vip_status=1;
13. UPDATE account SET balance=balance-10 WHERE balance<500 AND vip_status=0;
阅读全文