答案 0 :(得分:1)
您可以使用简单的OR
来完成此操作:
SELECT Account, Invoice, Company, DaysSent
FROM YourTable
WHERE Company NOT IN('MMCR', 'HSSA')
OR (Company IN('MMCR', 'HSSA') AND DaysSent >= 90);
答案 1 :(得分:1)
或更简单的答案:
SELECT [Account], [Invoice #], [Company], [Days Sent]
FROM [dbo].[YourTable]
WHERE NOT ([Company] IN ('MMCR', 'HSSA') AND [Days Sent] < 90);
答案 2 :(得分:0)
这应该做到:
SELECT ACCOUNT, INVOICE, COMPANY, DAYS_SENT FROM TABLE1
WHERE (COMPANY = 'MMCR' AND DAYS_SENT >= 90) OR (COMPANY = 'HSSA' AND DAYS_SENT >= 90)
UNION
SELECT ACCOUNT, INVOICE, COMPANY, DAYS_SENT FROM TABLE1
ACCOUNT NOT IN (
SELECT ACCOUNT
WHERE (COMPANY = 'MMCR' AND DAYS_SENT >= 90) OR (COMPANY = 'HSSA' AND DAYS_SENT >= 90)
)
有很多方法可以解决此问题,我只是喜欢这种方法,因为我觉得它易于阅读和理解(尤其是以后要更新时!)
答案 3 :(得分:0)
You can do like this
SELECT ACCOUNT, INVOICE, COMPANY, DAYS_SENT FROM TABLE1
WHERE Company in ('MMCR', 'HSSA') AND DAYS_SENT >= 90
UNION
SELECT ACCOUNT, INVOICE, COMPANY, DAYS_SENT FROM TABLE1 Where
ACCOUNT NOT IN ('MMCR', 'HSSA')