Pregunta

I have the following SQL statement

(
    Select top 1 R.[Date] from dbo.[RTable] R where R.x
    IN (SELECT Number FROM dbo.xTable) 
    --(CASE when R.[date]> GETDATE() then 'y'
    --else
    --'n' end) 
    )as FieldName,

how to apply the case ? I comment it because it fail on Run , any help ?

¿Fue útil?

Solución 2

I fix the problem using this

(Select top 1(CASE when R.[date]>= GETDATE() then 'y' when R.[Date] is null then 'n' else 'n' end) 
from dbo.[table] R  where R.x=a.y) as field,

Otros consejos

It's not clear what you're wanting to do, but it looks a bit like you should have that as part of your select list:

SELECT TOP 1 R.[Date], 
    CASE when R.[date]> current_timestamp then 'y' else 'n' end as FieldName 
FROM dbo.[RTable] R 
WHERE R.x  IN (SELECT Number FROM dbo.xTable) 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top