我有以下表结构
AccountID Property Value
123456 Status Active
123456 City Los Angeles
123456 RegistrationDate 2018-05-11 11:30:14.000
543210 Status Active
543210 City Las Vegas
543210 RegistrationDate 2018-05-11 11:13:14.000
888888 Status Inactive
888888 City Toronto
888888 RegistrationDate 2015-05-12 11:13:14.000
Run Code Online (Sandbox Code Playgroud)
我希望能够选择 Property == Status 和 Value == Active And Property == RegistrationDate and Value == 2018-05-11 11:30:14.000 的所有行
我想我需要做某种 GROUP BY 然后选择那个聚合,但我无法理解它(我的 sql 真的很生疏)。
我想要上面“查询”的以下输出
AccountID Status RegistrationDate
123456 Active 2018-05-11 11:30:14.000
543210 Active 2018-05-11 11:30:14.000
Run Code Online (Sandbox Code Playgroud)
如果所有列都存在于同一行中,我会这样写:
SELECT AccountID FROM Property
WHERE Status = …
Run Code Online (Sandbox Code Playgroud)