信用卡常用的回收统计SQL
时间: 2023-07-01 12:22:46 浏览: 59
信用卡常用的回收统计SQL可以根据具体的数据结构和业务需求进行调整,下面提供一个基本的范例:
```
SELECT
COUNT(*) AS total_count, -- 回收总数
SUM(amount) AS total_amount, -- 回收总金额
AVG(amount) AS avg_amount, -- 平均回收金额
MAX(amount) AS max_amount, -- 最大回收金额
MIN(amount) AS min_amount -- 最小回收金额
FROM
credit_card_repayments
WHERE
repayment_date BETWEEN '2021-01-01' AND '2021-12-31'; -- 回收时间范围
```
在实际业务中,可能需要根据不同的维度进行统计,例如按照信用卡类型、回收渠道、回收人员等维度进行统计,可以根据具体情况添加 GROUP BY 子句和聚合函数进行统计。同时,也可以根据具体需求添加其他条件进行过滤,例如回收状态、回收方式等条件。
相关问题
信用卡常用回收率sql
以下是信用卡常用的回收率SQL语句:
1. 计算信用卡回收率:
```
SELECT SUM(payment_amount) / SUM(amount) AS recovery_rate
FROM credit_card_statement
JOIN credit_card_payment ON credit_card_statement.card_number = credit_card_payment.card_number
AND credit_card_statement.statement_date = credit_card_payment.payment_date
WHERE credit_card_statement.card_number = 'xxxx-xxxx-xxxx-xxxx';
```
2. 计算信用卡最近三个月的回收率:
```
SELECT SUM(payment_amount) / SUM(amount) AS recovery_rate
FROM credit_card_statement
JOIN credit_card_payment ON credit_card_statement.card_number = credit_card_payment.card_number
AND credit_card_statement.statement_date = credit_card_payment.payment_date
WHERE credit_card_statement.card_number = 'xxxx-xxxx-xxxx-xxxx'
AND credit_card_statement.statement_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW();
```
3. 计算信用卡不同消费类型的回收率:
```
SELECT category, SUM(payment_amount) / SUM(amount) AS recovery_rate
FROM credit_card_statement
JOIN credit_card_payment ON credit_card_statement.card_number = credit_card_payment.card_number
AND credit_card_statement.statement_date = credit_card_payment.payment_date
WHERE credit_card_statement.card_number = 'xxxx-xxxx-xxxx-xxxx'
GROUP BY category;
```
4. 计算信用卡不同持卡人的回收率:
```
SELECT card_holder, SUM(payment_amount) / SUM(amount) AS recovery_rate
FROM credit_card_statement
JOIN credit_card_payment ON credit_card_statement.card_number = credit_card_payment.card_number
AND credit_card_statement.statement_date = credit_card_payment.payment_date
WHERE credit_card_statement.card_number = 'xxxx-xxxx-xxxx-xxxx'
GROUP BY card_holder;
```
信用卡常用的sql
以下是信用卡常用的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;
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)