信用卡常用的sql
时间: 2023-08-23 11:18:28 浏览: 44
以下是信用卡常用的SQL语句:
1. 查询信用卡账单总额:
```
SELECT SUM(amount) AS total_amount
FROM credit_card_statement
WHERE card_number = 'xxxx-xxxx-xxxx-xxxx' AND statement_date BETWEEN '2021-01-01' AND '2021-03-31';
```
2. 查询信用卡账单明细:
```
SELECT transaction_date, description, amount
FROM credit_card_statement
WHERE card_number = 'xxxx-xxxx-xxxx-xxxx' AND statement_date = '2021-03-31';
```
3. 查询信用卡可用额度:
```
SELECT credit_limit - SUM(amount) AS available_limit
FROM credit_card_statement
WHERE card_number = 'xxxx-xxxx-xxxx-xxxx';
```
4. 查询信用卡还款记录:
```
SELECT payment_date, payment_amount
FROM credit_card_payment
WHERE card_number = 'xxxx-xxxx-xxxx-xxxx';
```
5. 查询信用卡逾期记录:
```
SELECT statement_date, amount
FROM credit_card_statement
WHERE card_number = 'xxxx-xxxx-xxxx-xxxx' AND due_date < CURDATE() AND paid_date IS NULL;
```
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)