Skip to content

Commit 99cb0c0

Browse files
committed
comapre 쿼리 수정
1 parent 5a355d3 commit 99cb0c0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

dao/etfCompareDao.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ const getEtfOneDao = async (connection, etfCode, userId) => {
22
const sql = `
33
WITH user_weights AS (
44
SELECT
5-
stability_weight,
6-
liquidity_weight,
7-
growth_weight,
8-
diversification_weight
9-
FROM users
10-
WHERE user_id = $2
5+
stability_weight / total AS stability_weight,
6+
liquidity_weight / total AS liquidity_weight,
7+
growth_weight / total AS growth_weight,
8+
diversification_weight / total AS diversification_weight
9+
FROM (
10+
SELECT
11+
stability_weight,
12+
liquidity_weight,
13+
growth_weight,
14+
diversification_weight,
15+
(stability_weight + liquidity_weight + growth_weight + diversification_weight) AS total
16+
FROM users
17+
WHERE user_id = $2
18+
) raw_weights
1119
),
1220
user_input AS (
1321
SELECT ($3 / 30.0) * 100.0 AS user_score_100

0 commit comments

Comments
 (0)