Home > Software engineering >  Exclude a value from AVG in SQL
Exclude a value from AVG in SQL

Time:08-26

I have a table where i have to find the avg price of an item, the problem is that i have to exclude a payment option from the avg

lets say the table goes like this Example

enter image description here

I want to remove cash payments from this avg

CodePudding user response:

Just add a WHERE statement to filter out cash payments.

SELECT AVG(total)
FROM yourtable
WHERE payment != 'cash'
  • Related