| SQL |
select top 20 mfr.mfr_name, sku.skuDesc, cdr.cdr_dstName, o.availableDate, opr.companyName
from tbl_SPL_Opportunities o with (nolock)
inner join tblManufacturers mfr with (nolock)
on mfr.mfr_id = o.mfrId
inner join tbl_SPL_OpportunitySubjectDetails osd with (nolock)
on osd.opportunityId = o.opportunityId
and osd.ownerId = o.ownerId
and osd.ownerType = o.ownerType
inner join tbl_PRD_Skus sku with (nolock)
on sku.skuId = osd.subjectDetailId
and sku.ownerId = osd.ownerId
and sku.fsl_tablecode = osd.ownerType
inner join tbl_CDR_Distributors cdr with (nolock)
on cdr.fsl_tablecode = o.ownerType
and cdr.ownerId = o.ownerId
and cdr.cdr_recordId = o.cdrDistributorId
inner join tbl_OPR_ClientOperators opr with (nolock)
on opr.ownerId = o.ownerId
and opr.fsltablecode = o.ownerType
and opr.operatorId = o.partnerId
where o.ownerId = 387
and o.ownerType = 'BRO'
and o.opportunityId = 6231094 |