SQL - Conditional return of data

MBoy
MBoy used Ask the Experts™
on
I'd like to remove any value from Data1 that is less than < 99

CREATE PROCEDURE [dbo].[KeyReportsAllEventsByOperator]
(
            @Operator As varchar(200)
)
AS
BEGIN
     SELECT
         [EventDateTime] As Date,
             [Vehicle],
             [Operator],
         [EventType] As Event,            
         [Data1],
         [Data2]
     FROM
         [RemoteData]
      WHERE @Operator = [Operator]
       ORDER BY [EventDateTime] DESC
END
GO
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you want to exclude the recrods which have Data 1 less than 99 use below:

CREATE PROCEDURE [dbo].[KeyReportsAllEventsByOperator]
(
            @Operator As varchar(200)
)
AS
BEGIN
     SELECT
         [EventDateTime] As Date,
             [Vehicle],
             [Operator],
         [EventType] As Event,            
         [Data1],
         [Data2]
     FROM
         [RemoteData]
      WHERE @Operator = [Operator] AND [DATA 1]<99
       ORDER BY [EventDateTime] DESC
END
GO

Do you want to update the records where Data 1<99?

Thanks,

Author

Commented:
I don't want lose the record row.  I want to change [Data1] = 1 to [Data1] = ""
Software Engineer
Commented:


CREATE PROCEDURE [dbo].[KeyReportsAllEventsByOperator]
(
            @Operator As varchar(200)
)
AS
BEGIN
     SELECT
         [EventDateTime] As Date,
             [Vehicle],
             [Operator],
         [EventType] As Event,            
         case when Data1 < 99 then '' else cast(Data1 as varchar) end [Data1]
         [Data2]
     FROM
         [RemoteData]
      WHERE @Operator = [Operator]
       ORDER BY [EventDateTime] DESC
END

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial