Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding to case statement

Status
Not open for further replies.

nc297

Programmer
Apr 7, 2010
162
US
How can I add this to the case statement of the query or just to the query to check...

If fileddate <> filedate then use the min filedate and place in the title field the word 'concurr' for the one record.

I have this query doing it already but it does it for filedates matching.

Select distinct p.CLMS, p.DOC,
p.Reg,
n.RegionAcronym,
p.FO,



Age = Datediff(day,max(p.filedate), getdate()),
FileDate = max(FileDate),
o.mailingaddressstate as DDS,
o.ddsofficecode as DDSCode,
Min(ddsrcpt) AS DDSReceipt,
DDSAge = Datediff(day,min(p.ddsrcpt), getdate()),
Title = case when min(p.Title) <> max(p.Title) then 'Concurr' else min(p.Title) end
From pendingdds p
join Offices.dbo_OfficeCodes d
on d.officecode = p.doc
join natdocfile n
on n.doc = p.fo
join offices.dbo.doorsinfo o
on o.officecode = p.fo
where p.doc ='s09'
AND ( Datediff(DAY, filedate, Getdate()) > 300 )
Group By p.fo, p.Reg, n.regionacronym,p.DOC, p.CLMS, o.ddsofficecode,
o.mailingaddressstate
order by clms


How can I add to the bold section or add on to the title section to get what I want.
 
Instead of MIN(p.Title) = max(p.Title) you seem to want to check
MIN(case when FiledDate <> FileDate then 'Concurr' else 'Z' + Title end) as Title

Use it in derived table and get rid of the 'Z' in the final select.

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top