COZYHUB
  • Home
  • Disclaimer
  • Privacy Policy
  • About
  • Contact

How to sort a column using a custom order in amazon athena?


to sort this column

abc

to get this output

bac

the mysql clause order by field(col,'b','a','c') does not work in athena. is there an equivalent?

1

Best Answer


You can use a case when for getting this order:

ORDER BY CASE WHEN col='b' THEN 1WHEN col='a' THEN 2WHEN col='c' THEN 3ELSE 4 END ASC

Random Posts

-bash: !": event not found [closed]How to connect to MariaDB by means of python?Get first row value of a given columnHow to pad the left side of a list of tensors in pytorch to the size of the largest list?How to round up value C# to the nearest integer?typeof operator in CI am using unofficial package of stockx api in javascript but i am getting the following error while using login apiHow to emulate in Java the behavior of RPG Z-ADD or other assignment that would be an overflow?How to remove specific special characters in Rreturn max value from a list of dictionary in pythonhow to start developing with OpenText CASE360Cannot find module acorn.jsHow to type Redux actions and Redux reducers in TypeScript?Cannot renew RHEL 7.6 Developer account subscriptionHow to modify kernel DTB fileWhat is sys.maxint in Python 3?Google Drive API v3 files.export method throws a 403 error: "Export only supports Docs Editors files."How do you pass a function as a parameter in C?Unable to ravel a numpy arrayRate and sleep function in RCLPY library for ROS2
Designed by COZYHUB