Jump to content

SQL query help


Andrejkov

Recommended Posts

Hello,

I need help with writing a SQL query wwhich I will be able to extract from the database information on the discount codes used, but in a summed form, i.e. how much a given code has been used and what is the total sum of values of orders.

Query: SELECT * FROM `ps_order_cart_rule` returns to me the entire contents of the table, now I need to get the discount code "Your first buy" from this data and return how many times this code has been used and what is the total value of orders using this code.

Thank you very much in advance for your help.

 

zapytanie.jpg

Link to comment
Share on other sites

2 hours ago, abdullacm said:
SELECT name, COUNT(*) AS total_used, SUM(value) AS total_value
FROM ps_order_cart_rule
GROUP BY name

try this sql :)

There is other problem with  this query in column "value" i have only discount value but I need to compare this data with orders value. How i Can modify this query to get a orders value from "id_order".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...