How to find the first row which has value not equal to Zero

Viewed 2401

I need to find the first date where Ten_Yr_CAPE is not having 0 value. Output table should have Country column and Date Column on which has Date when Ten_Yr_CAPE became greater than 0.

I wrote the below query but it pulling all records having 'Ten_Yr_CAPE' <> 0. I need only the initial date. Can anyone help me.

Select TOP(1) returns only one record. I need one record for each country. So totally 20 records for each country

    select  [Date],[Country] from [Tableau].[dbo].[Country_table4$] where 
    [Ten_Yr_CAPE] <> 0 
     Group by [Country], [Date]
     Order by [Date] ASC
3 Answers
Related