sql - How query works with missing Group by values -


i tryng write query pull total discount revenue of customer's orders day. note each ship_id there several items want have sum clauses below , in end, have group , want group them ship_id (this unique each order).

i got result of 2m rows (this correct because big) not sure if group correct. if put ship_id there? how query understands it?

            d.ship_id              ,to_char(d.order_datetime,'yyyy/mm/dd hh24:mi:ss') datetime_order             ,to_char(d.order_datetime, 'd') day_order             ,to_char(d.order_datetime, 'mm') month_order             ,sum(di.discount) discount              ,sum(di.price * di.units) price                        table1 d              join              table2 di             on                  d.ship_id = di.ship_id        group             d.ship_id             ,to_char(d.order_datetime,'yyyy/mm/dd hh24:mi:ss')              ,to_char(d.order_datetime, 'd')              ,to_char(d.order_datetime, 'mm')  

in query grouping result by

  • ship_id (order)
  • d.order_datetime yyyy/mm/dd hh24:mi:ss (i think wrong if need group day) group grouping day,month,year,hour,minute , seconds

  • d.order_datetime 'd' (grouping day correct)

  • d.order_datetime 'mm' (grouping month correct, doesn't change results of grouping day)

p.s.: dont see grouping costumer in anywhere.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -