September 13, 2012 at 5:11 am
dwain.c (9/13/2012)
ChrisM@Work (9/13/2012)
SELECT
Id, A, B, C,
MinVal
FROM #MinAmt
CROSS APPLY (
SELECT MIN(a)
FROM (VALUES (A),(B),(C) ) v (a)
WHERE a > 0
) x (MinVal)
And the referee throws down a red penalty flag!
This is the SQL 2005 forum!
Challenged! texpic always posts in the 2K8 forum!
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 13, 2012 at 6:33 am
Try This
select Id,MIN(a) from (
select a.id, a.a from #MinAmt a ,#MinAmt
union
select a.id, a.b from #MinAmt a ,#MinAmt
union
select a.id, a.c from #MinAmt a ,#MinAmt
) a where a>0 group by Id
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy