다음 조건에 대해 데이터베이스를 쿼리해야한다는 요구 사항이 있습니다.n 번을 사용하여 데이터베이스에서 데이터 가져 오기
데이터베이스 [리포트 당겨] 우리는 내가 지난 30 일 기록을 가지고 있지만 정확히 기록이없는 한 모든 고객을 찾을 필요가있는 2 열
에게 CustomerID를 ReportDt
말을 할 수있다 (오늘 - 30) 다른 조건 중.
Select Condition on [Report Pull] PR
and cast(PR.ReportDt as Date) = cast(getdate()-30 as date)
and not exists (
select PR2.*
from [Report Pull] PR2
where 1=1
and cast(PR2.ReportDt as Date) > cast(getdate()-30 as date)
and PR2.CustomerId = PR.CustomerId
)
지금 내가 매 30 일이되도록
cast(getdate()-30 as date) is mod30 = 0
AND at the same time
cast(PR2.ReportDt as Date) > cast(getdate()-30 as date)
Next
cast(getdate()-60 as date) is mod30 = 0
AND at the same time
cast(PR2.ReportDt as Date) > cast(getdate()-60 as date)
that is no report pulled in last 60 days
등을 고객을 끌어합니다. 이는 db가 여러 개의 보고서 끌어 오기 레코드를 가질 수 있기 때문입니다. 조금 혼란 스럽지만 제발 도와주세요. :)
SQL에서는 변수를 선언 할 수 없습니다. DB는 Salesforce Marketing입니다. CLoud 일명 ExactTarget입니다.