Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now
-- SQL Query 1:- with p as ( select TR.[Generic Code], TR.NDC, TR.[Drug Name], Sum(TR.[Dispensed Qty]) as Qty from TransactionReport TR Group By TR.[Generic Code], TR.NDC,TR.[Drug Name] ) select x.[Generic Code], x.NDC, x.[Drug Name], y.Qty from ( select p.*, row_number() over (partition by [Generic Code] order by Qty desc) rn from p ) x left join ( select [Generic Code], sum(Qty) Qty from p group by [Generic Code] ) y on x.[Generic Code]=y.[Generic Code] where rn=1; -- SQL Query 2 select Dr.GenericCode as [Generic Code],Br.NDC as [NDC],Dr.Name as [Drug Name],Br.Qty as [Qty] from BalanceReport Br Left Join Drug Dr on stuff(Dr.DrugNDCNbr,case when Dr.DrugNDCType in (50, 56) then 1 when Dr.DrugNDCType in (51, 57) then 6 when Dr.DrugNDCType = 52 then 10 end, 0, '0') = Br.NDC
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.