Avatar of AXISHK
AXISHK

asked on 

MAX function

suppose the records in a table containing the records below :

inventbatchid       itemid     a2      a3       a4      PIC3            
PO10901                 AB0001    A       DX      20       c:\photo\abc135.jpg
PO10901                 AB0001    A       DX      20       c:\photo\abc13512321321.jpg
PO10901                 AB0001    A       DX      20       c:\photo\ac135.jpg

In this case, which record will be returned by "MAX" function ? Tks

select inventbatchid,itemid,a2,a3,a4,
 Tent,
 max(case typeid when 'ImgS' then pic else '' end) as 'PIC3',
 max(case typeid when 'sketchA' then pic else '' end) as 'PIC2',
 max(case typeid when 'sketchB' then pic else '' end) as 'PIC1'  
into #tmp3 from #tmp2
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
AXISHK
Avatar of PortletPaul
PortletPaul
Flag of Australia image

without typeid in the data we cannot answer

ie. the case expressions require a value in the field typeid, that value is not provided in your data
Avatar of AXISHK
AXISHK

ASKER

TypeID will be either 'IMgS', 'sketchA' and 'sketchB'. In the example above, typeID is 'ImgS'.
Avatar of PortletPaul
PortletPaul
Flag of Australia image

which record will be returned by "MAX" function ?
c:\photo\ac135.jpg
Avatar of AXISHK
AXISHK

ASKER

What's the selection criteria ?
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of AXISHK
AXISHK

ASKER

Tks
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo