Reputation: 79
I have 2 tables I want to select the records from the Requirement table that has RService and RSubService = 'No Requirement' in last 15 days and who corresponding MobileIT and PhoneIT in the table EnquiryMaster table are null or not entered
EnquiryMaster
[EnquiryId]
,[Company]
,[HeadOfficeAddress]
,[ContactPersonIT]
,[EmailIT]
,[MobileIT]
,[PhoneIT]
,[date]
Requirement-
[RequirementID]
,[EnquiryID]
,[Company]
,[RService]
,[RSubService]
,[RDetails]
,[RDate]
Upvotes: 0
Views: 75
Reputation: 1369
select *
from dbo.EnquiryMaster as em
left join dbo.Requirement as r
on em.EnquiryId = r.EnquiryID
where r.MobileIT is null
and r.PhoneIT is null
and em.RService ='No Requirement'
and em.RSubService ='No Requirement'
and em.date >= dateadd(day, -15, getdate())
Upvotes: 2
Reputation: 439
select * from EnquiryMaster e, Requirement r
where e.EnquiryId = r.EnquiryID
and RService = 'No Requirement'
and RSubService = 'No Requirement'
Upvotes: 1
Reputation: 147
select * from EnquiryMaster em
inner join Requirement r on r.EnquiryId = em.EnquiryID
where r.MobileIT is null and r.PhoneIT is null and em.RSubService ='No Requirement'
Upvotes: 1