TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pinku
1.4k
302
45.3k
How to merge sql query
Aug 30 2019 4:15 AM
select tctp.AccountDID, tp.rdbslicecode as [ProductSlice], Sum(isnull(tctp.Quantity,0)) as [ProductCount],
Max(CASE WHEN LevelCapability = 'RecruitEdgeRDB' THEN 'Named License' ELSE '' END ) AS [LicenseModel] into #ProductAudit from productdata.dbo.HHContractProduct
tctp with(nolock) inner join ProductData..hhproduct tp with(nolock) on tp.productid=tctp.productid where tctp.StatusCode='Active' and
tctp.LevelCapability in ('ResumeAccess','RDBSeat','RecruitEdgeRDB','NamedRDBAccess') and tctp.ActiveStartDT<=getdate() and
tctp.ActiveEndDT>=getdate() and tp.ProductID not in ('FM12RDB') and tp.RDBProductType<>'ViewBased' and tctp.AccountDID='AJ26106LNFG47J6YXMD'
Group by tctp.AccountDID, tp.rdbslicecode,tctp.LevelCapability
this query retun the result as below
AccDid productslice productcount licenseModel
===================================================================
AJ26106LNFG47J6YXMD US 1 Named License
AJ26106LNFG47J6YXMD US 1
but i want the result like below
AccDid productslice productcount licenseModel
===================================================================
AJ26106LNFG47J6YXMD US 2 Named License
Reply
Answers (
1
)
Objects explorer opening slowly
How to do a SUM inside a CASE WHEN clause