I have a query that returns the date,value, and category:
SELECT Date, Value, Category FROM MyTable
Outputs:
18-Dec-2011 || 6 || Toys 01-Apr-2012 || -4 || Dog Collars 31-May-2012 || 4 || Cat 17-Dec-2011 || 3 || Health & Hygiene 12-Dec-2011 || 3 || Travel & Training
When I add Order By Date ASC it puts the date in ascending order based on the date not the year.
I want it to look like this:
12-Dec-2011 || 3 || Travel & Training 17-Dec-2011 || 3 || Health & Hygiene 18-Dec-2011 || 6 || Toys 01-Apr-2012 || -4 || Dog 31-May-2012 || 4 || Cat
Note: Date is of type string. I am using
google-bigquery.
How can I get the year in ascending order first, followed by the month, and then date?
Update: as FH below says, “BigQuery has a Timestamp type now: developers.google.com/bigquery/timestamp”
BigQuery does not currently have a Date or DateTime datatype.You could also store your datestamps in BigQuery as integers in POSIX (UNIX epoch) date format, and can convert them to human readable time using the FORMAT_UTC_USEC function.An alternative would be to store datestamps as strings in the
YYYY-MM-DD HH:MM:SS.uuuuuuformat, convert them in your ordered query using the PARSE_UTC_USEC() function.