Re: Select statement and conditional value

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Roji. P. Thomas (lazydragon_at_nowhere.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 21:58:58 +0530

SELECT ac.ServerID, ac.PolicyID, ac.Status, ac.CurrentValue,
CASE WHEN pd.Automated = 1 Then '*' + pi.PolicyText ELSE pi.PolicyText END
AS PIText,
pi.PolicyIPM, pd.Automated AS audComplianceStatus
FROM auxtatus ac INNER JOIN
                      auxInfo pi ON pi.PolicyID =
ac.PolicyID INNER JOIN
                      auxDetail pd ON pi.PolicyID =
pd.PolicyID
WHERE (ac.ServerID = 351) AND (ac.Status = 0) AND
(pd.OS = 'WINDOWS')
ORDER BY ac.PolicyID

-- 
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Jim Abel" <jim.abel@lmco.com> wrote in message
news:2dd301c4a577$2ac177f0$a501280a@phx.gbl...
> I'm thought that I saw or read something that showed how
> I could return a text column or a concanted column
> depending on the value of another field in a select
> statement.  See the following statement.
>
> SELECT     ac.ServerID, ac.PolicyID, ac.Status,
> ac.CurrentValue, pi.PolicyText AS PIText, pi.PolicyIPM,
> pd.Automated AS audComplianceStatus
> FROM         auxtatus ac INNER JOIN
>                       auxInfo pi ON pi.PolicyID =
> ac.PolicyID INNER JOIN
>                       auxDetail pd ON pi.PolicyID =
> pd.PolicyID
> WHERE     (ac.ServerID = 351) AND (ac.Status = 0) AND
> (pd.OS = 'WINDOWS')
> ORDER BY ac.PolicyID
>
>
>
> What I really want is if the Automated field is true
> (it's a bit field with either 1or 0) I would like to
> append an astrisk "*" to the beginning of the PolicyText
> value other wise just return the PolicyTest value
>
> Is this possible? if so what does the syntax look like?
>
> Thanks