0

How to filter null values

The Y! Finance team has the habit of changing symbols every other day for the Amsterdam Exchange (symbols ^aex or aex.nx). Now I want to query both symbols and filter out the one that has a null value for a certain key. Here's the regular query without the filter and the result payload:

CODE
select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc")

"results":{
"quote":[{
"symbol":"^AEX",
"Change":"-0.82",
"Name":"AEX"
},
{
"symbol":"AEX.NX",
"Change":null,
"Name":"AEX.NX"
},
{
"symbol":"^IXIC",
"Change":"0.00",
"Name":"NASDAQ Composite"
},
{
"symbol":"^GSPC",
"Change":"0.00",
"Name":"S&P 500 INDEX,RTH"
}
]
}


When I try this, YQL throws an error:

CODE
select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc") and Change != null

Internal Error Only supported Identifier is 'me'


And when doing this, it also filters out the "0.00" string values...

CODE
select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc") and Change != 0

"results":{
"quote":{
"symbol":"^AEX",
"Change":"-0.40",
"Name":"AEX"
}
}


Any clue?

by
4 Replies
  • QUOTE (Ivo @ Jul 23 2009, 12:18 AM) <{POST_SNAPBACK}>
    The Y! Finance team has the habit of changing symbols every other day for the Amsterdam Exchange (symbols ^aex or aex.nx). Now I want to query both symbols and filter out the one that has a null value for a certain key. Here's the regular query without the filter and the result payload:

    CODE
    select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc")

    "results":{
    "quote":[{
    "symbol":"^AEX",
    "Change":"-0.82",
    "Name":"AEX"
    },
    {
    "symbol":"AEX.NX",
    "Change":null,
    "Name":"AEX.NX"
    },
    {
    "symbol":"^IXIC",
    "Change":"0.00",
    "Name":"NASDAQ Composite"
    },
    {
    "symbol":"^GSPC",
    "Change":"0.00",
    "Name":"S&P 500 INDEX,RTH"
    }
    ]
    }


    When I try this, YQL throws an error:

    CODE
    select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc") and Change != null

    Internal Error Only supported Identifier is 'me'


    And when doing this, it also filters out the "0.00" string values...

    CODE
    select symbol, Name, Change from yahoo.finance.quotes where symbol in ("^aex","aex.nx","^ixic","^gspc") and Change != 0

    "results":{
    "quote":{
    "symbol":"^AEX",
    "Change":"-0.40",
    "Name":"AEX"
    }
    }


    Any clue?



    Ivo,

    Can you try "is not null" in your query? Like so:
    CODE
    Change is not null


    -- Nagesh
    0
  • Here's what the doc says about "is not null":

    CODE
    IS [NOT] NULL

    Tests for the existence of the field in the results. An IS NULL expression is true if
    the field is not in the results.


    So this doesn't fly since the field exists...

    -Ivo
    0
  • QUOTE (Ivo @ Jul 23 2009, 09:47 PM) <{POST_SNAPBACK}>
    Here's what the doc says about "is not null":

    CODE
    IS [NOT] NULL

    Tests for the existence of the field in the results. An IS NULL expression is true if
    the field is not in the results.


    So this doesn't fly since the field exists...

    -Ivo


    How about
    and Change not matches "(?!.)"
    0
  • QUOTE (hapdaniel @ Jul 23 2009, 11:48 PM) <{POST_SNAPBACK}>
    How about
    and Change not matches "(?!.)"


    Yeah, nice regex and it works in this case! Still would like to filter a real null value...

    cheers, Ivo
    0

Recent Posts

in YQL