Spaces:
Sleeping
Sleeping
ktsn-ud commited on
Commit ·
461aec2
1
Parent(s): 57d180e
テキストデータが複数ある場合にupdateAtが最新のもののみを取ってくるようにSQL文を変更
Browse files- app/repositories/query.sql +15 -6
app/repositories/query.sql
CHANGED
|
@@ -24,12 +24,21 @@ JOIN `Circle` AS c
|
|
| 24 |
-- テキスト情報を結合
|
| 25 |
LEFT JOIN (
|
| 26 |
SELECT
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
FROM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
GROUP BY pt.circleProjectId
|
| 34 |
) AS texts
|
| 35 |
ON texts.circleProjectId = cp.id
|
|
|
|
| 24 |
-- テキスト情報を結合
|
| 25 |
LEFT JOIN (
|
| 26 |
SELECT
|
| 27 |
+
pt.circleProjectId,
|
| 28 |
+
MAX(CASE WHEN pt.textType = 'DESCRIPTION' THEN pt.content END) AS description,
|
| 29 |
+
MAX(CASE WHEN pt.textType = 'PRSUMMARY' THEN pt.content END) AS prSummary,
|
| 30 |
+
MAX(CASE WHEN pt.textType = 'PRDETAIL' THEN pt.content END) AS prDetail,
|
| 31 |
+
MAX(CASE WHEN pt.textType = 'REMARK' THEN pt.content END) AS remark
|
| 32 |
+
FROM (
|
| 33 |
+
SELECT
|
| 34 |
+
*,
|
| 35 |
+
ROW_NUMBER() OVER (
|
| 36 |
+
PARTITION BY circleProjectId, textType
|
| 37 |
+
ORDER BY updatedAt DESC
|
| 38 |
+
) AS rn
|
| 39 |
+
FROM ProjectText
|
| 40 |
+
) pt
|
| 41 |
+
WHERE pt.rn = 1
|
| 42 |
GROUP BY pt.circleProjectId
|
| 43 |
) AS texts
|
| 44 |
ON texts.circleProjectId = cp.id
|