0
outer apply 
( 
isnull(
    (select top 1

        sea.Daily,          
        sea.SeasonId    
    from Season as sea      
    where sea.propertyId = prop.PropertyId and FromDate < @FromDate and  ToDate > @ToDate   
    ),
    (select top 1 sea.Daily,            
        sea.SeasonId            
        from Season as sea where sea.propertyId = prop.PropertyId)
    )           
) as pri

Write error Incorrect syntax near ')'. Incorrect syntax near the keyword 'as'.

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
Tatti
  • 23
  • 4

1 Answers1

1

Missing "Select"??

outer apply 
( 
SELECT isnull(
    (select top 1

        sea.Daily,          
        sea.SeasonId    
    from Season as sea      
    where sea.propertyId = prop.PropertyId and FromDate < @FromDate and  ToDate > @ToDate   
    ),
    (select top 1 sea.Daily,            
        sea.SeasonId            
        from Season as sea where sea.propertyId = prop.PropertyId)
    )           
) as pri

Raj

Raj
  • 10,653
  • 2
  • 45
  • 52
  • Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. – Tatti Aug 26 '13 at 10:38
  • @Tatti maybe you can *try* to fix the error yourself. Raj has given you the solution basically. – usr Aug 26 '13 at 11:09
  • thanks for the tip), a lot of ideas but need a working solution – Tatti Aug 26 '13 at 12:35
  • @Tatti - the error shown in your comment does not come for this code segment you have posted in your question. Post entire query – Raj Aug 27 '13 at 07:40
  • Thanks, decided to issue in a different way – Tatti Aug 27 '13 at 08:03