Home > Blockchain >  Sum of two columns as criteria
Sum of two columns as criteria

Time:10-04

I am trying to match product entries by their surface.

My thought was that the below query should be valid.

But it doesn't work, I am receiving:

Unknown column 'surface' in 'where clause'

SELECT SUM(width*height) AS surface FROM products WHERE surface>50

CodePudding user response:

The function sum is not for this use case. With sum you get the sum of all rows. What you are looking for is.

SELECT (width*height) AS surface FROM products WHERE surface>50

CodePudding user response:

This works:

 SELECT * FROM products WHERE (width*height)>50
  • Related