I am trying to build the following sp :
USE [MarMoniApp]
GO
/****** Object: StoredProcedure [dbo].[Desc_by_date] Script Date: 10/23/2012 09:01:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Desc_by_date]
@DateToSearch varchar(50)
AS
BEGIN
select a.ticker,a.First_T, a.Last_T, a.Size_mln, a.pct_d_vol,a.a_trad,a.coolname,a.recency,b.Analyst
from Order_Desc a
CASE
When a.coolname = 'ELTORO'
then (Inner join MarMoniApp.dbo.Namelist b on a.ticker = b.ticker )
END
where convert(datetime, cast(rtrim(First_T) AS nvarchar)) > DateToSearch
order by CONVERT(DATETIME, cast(rtrim(First_T) AS nvarchar) ) DESC
END
I want to do the inner join only if the “coolname” is equal to eltoro, but it seems that my syntax is not correct.
What about making two select statement and then union them.