Order by time sql response when extraction using json format -


i having database contain timestamp , data. data json.

in need sort result of select time.

normally doing :

select *  mytable  userid = 'sebastien'  order ts desc 

ts timestamp. working fine constraint response supposed formatted array of json obj. in case, do:

select array_to_json(array_agg(row_to_json(mytable)))  mytable  userid = 'sebastien'; 

this returning want not ordered.

i have tried :

select array_to_json(array_agg(row_to_json(mytable)))  mytable  userid = 'sebastien'  order ts desc; 

but it's returning error:

column "mytable.ts" must appear in group clause or used in aggregate function

any idea?


Comments

Popular posts from this blog

The SDK directory does not exist (ubuntu 16.04) (react native) -

python - How to clone or copy a list? -

string - Using python and postgres, variables within execute function? -