QA@IT
«回答へ戻る

回答を投稿

サブクエリでUNIONを使う方法はいかがでしょうか。
( TOP 50 はSQL Serverの場合です)

SELECT TOP 50
*
FROM (
 SELECT
 aaa AS col1,
 bbb AS col2,
 created_at
 FROM Table1

 UNION ALL

 SELECT
 ccc AS col1,
 '---' AS col2,
 created_at
 FROM Table2
) t
ORDER BY t.created_at DESC
サブクエリでUNIONを使う方法はいかがでしょうか。
( `TOP 50` はSQL Serverの場合です)

```sql
SELECT TOP 50
*
FROM (
 SELECT
 aaa AS col1,
 bbb AS col2,
 created_at
 FROM Table1

 UNION ALL

 SELECT
 ccc AS col1,
 '---' AS col2,
 created_at
 FROM Table2
) t
ORDER BY t.created_at DESC
```