Options

How to query on json data ?

edited November 2017 in General Discussion

hello,
I was loaded json data into flex table

when i fetched days,it shows like this

how to in query on data array ??
ex: select maptostring(days=4) from testing_view ;

ERROR 4286: Operator does not exist: long varbinary = int
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts

How to query on this please provide a solution
Thanks in advance

Best Answer

  • Options
    edited November 2017 Answer ✓

    I got the solution o:)

    select id from testing where mapcontainsvalue(__raw__['days'],'2')='t' ;
    

    this will give u exact id's which 2 value contains

Answers

  • Options
    edited November 2017

    plz provide solution i need that query :'( #Jim_Knicely

  • Options
    Jim_KnicelyJim_Knicely - Select Field - Administrator
    edited November 2017

    Maybe the MAPITEMS function can help?

    dbadmin=> select maptostring(days) from testing_view;
                                        maptostring
        ---------------------------------------------------------------------------
         {
           "0" : "3",
           "1" : "4",
           "2" : "5",
           "3" : "2",
           "4" : "3"
        }
    
         {
           "0" : "1",
           "1" : "2",
           "2" : "3",
           "3" : "1",
           "4" : "3"
        }
    
        (2 rows)
    
    dbadmin=> select values from (select mapitems(days) over(partition best)from testing_view) foo where keys = 4;
     values
    --------
     3
     3
    (2 rows)
    
    dbadmin=> select values from (select mapitems(days) over(partition best)from testing_view) foo where keys = 0;
     values
    --------
     3
     1
    (2 rows)
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file