Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 586 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get order output after using group in the sql query?

#1
I have a my sql table with customer names and orders that they placed over time.

table column names are id, customer name, order value, status, and created and modified.

I am able to group customer names and number of orders.

using a sql query like this..

SELECT Customer,count(OrderPrice) FROM Orders GROUP BY Customer

It works fine. But I want the output to be ordered by number of orders(count). Customer with lots of orders comes at the top of the list.

I appreciate any help.

Thanks.
Reply

#2
SELECT Customer,
count(OrderPrice) order_count
FROM Orders
GROUP BY Customer
ORDER BY order_count desc


Enjoy!
Reply

#3
SELECT Customer
, count(OrderPrice) cnt
FROM Orders
GROUP BY Customer
ORDER BY cnt DESC
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through