sql - SQL Server 临时表从其他临时表插入
问题描述
临时表1
Col1 = Category1
Col1 = Category2
临时表2
30 records for a month
我如何为每个类别显示 30 条记录,因此结果将显示 60 条记录
解决方案
你需要cross join
:
select t1.*, t2.category
from table1 t1 cross join
(select distinct category from table2) t2;
但是,如果您没有重复项,则可以直接将其表示为:
select *
from table1 t1 cross join
table2 t2;
推荐阅读
- java - 如何将图像从 REST 服务方法返回到浏览器
- c# - 某些网站 FiddlerCore 的响应正文为空
- python - Python中的“通过”是什么类型?
- matlab - 如何避免在 MATLAB 中构造这些网格变量?
- javascript - 使用 jQuery 过滤嵌套的 JSON 以获取空值
- python - 异步 SQLite python
- java - 我如何能够在实现该接口的类中更改接口变量值
- python - 如何对mongodb进行不区分大小写的正则表达式搜索?
- android - layout-ldrtl 强制 paddingEnd 和 PaddingRight 而不是 PaddingLeft
- python - 如何正确包装单元测试差异?