我有一个数据表(结构不是很好),其中有以下内容
ClientID | Parameter | Value
111..........Street..........Evergreen
111..........Zip................75244
111..........Country.........USA
222..........Street..........Evergreen
222..........Zip................75244
222..........Country.........USA
333..........Street..........Evergreen
333..........Zip................75240
333..........Country.........USA
444..........Street..........Evergreen
444..........Zip................75240
444..........Country.........USA
555..........Street..........Evergreen
555..........Zip................75240
555..........Country.........USA
666..........Street..........Some Street
666..........Zip................75244
666..........Country.........USA
为此,我想选择所有在 Street = Evergreen 但也使用 ZIP 75244 的客户 ID,我有超过 700K 行,因此,全部导出将是一个大问题。
我的想法是:
SELECT ClientID
from (select ClientID from table1 where Value = 'evergreen')
Where Zip = '75244'
但在这种情况下它不会给我准确的结果我想获得 ClientIDs 111 和 222 的值,因为符合我正在寻找的标准 Street= Evergreen adn Zip=75244
有没有办法做到这一点?