Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 06-16-2016 09:18 AM
I have this so far:
select created_at, DATEDIFF(TO_DATE(current_date()), TO_DATE(sales_flat_order.created_at)) as delay, count(*) over() as NumberOfOrders FROM magentodb.sales_flat_order WHERE status IN ( 'packed' , 'cod_confirmed' ) GROUP BY TO_DATE(created_at)
But this is not working.
1. syntax error:
Error while compiling statement: FAILED: SemanticException [Error 10004]: Line 1:7 Invalid table alias or column reference 'created_at': (possible column names are: (tok_function to_date (tok_table_or_col created_at)))
2. count(*) does not give sum for each grouped by date but instead all of the rows.
Created 06-16-2016 03:06 PM
Hi @Simran Kaur. In your query you are trying to Group By "TO_DATE(created_at)" but the select statement does not retrieve that data. You are retrieving "created_at" and "DATEDIFF(TO_DATE(current_date()), TO_DATE(sales_flat_order.created_at))"
If you add "TO_DATE(created_at)" to your select list or changed your select list to use "TO_DATE(created_at)" instead of "created_at"... it should work.
Created 06-16-2016 09:23 AM
can you try with group by TO_DATE(sales_flat_order.created_at) -- considering sales_flat_order as table alias
Created 06-16-2016 09:25 AM
Na. did not work
Created 06-16-2016 09:32 AM
can you post 'show create table table_name' here?
Created 06-16-2016 03:06 PM
Hi @Simran Kaur. In your query you are trying to Group By "TO_DATE(created_at)" but the select statement does not retrieve that data. You are retrieving "created_at" and "DATEDIFF(TO_DATE(current_date()), TO_DATE(sales_flat_order.created_at))"
If you add "TO_DATE(created_at)" to your select list or changed your select list to use "TO_DATE(created_at)" instead of "created_at"... it should work.
Created 06-16-2016 04:17 PM
select TO_DATE(created_at),
DATEDIFF(TO_DATE(current_date()), TO_DATE(sales_flat_order.created_at)) as delay,
count(*) as NumberOfOrders
FROM
magentodb.sales_flat_order
WHERE
status IN ( 'packed' , 'cod_confirmed' )
GROUP BY TO_DATE(created_at),
DATEDIFF(TO_DATE(current_date()), TO_DATE(sales_flat_order.created_at))