Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张桌子Fact和Dimension. 维度包含两个字段ID和ObjectID。Fact 包含DimensionKey与IDin Dimension 的连接。ID是独一无二的,但ObjectID不是。这是一种版本控制机制。具有相同的所有行ObjectID实际上是同一对象的不同版本。
Fact
Dimension
ID
ObjectID
DimensionKey
我试图找到所有Facts指向Dimensions某个对象的所有版本的计数。
Facts
Dimensions
如果我理解正确,请尝试
SELECT d.objectid, COUNT(*) total_facts FROM fact f JOIN dimention d ON f.dimentionkey = d.id GROUP BY d.objectid