Saturday, February 25, 2012

Adding in a query

i want to add vales in a query

this is my scenario (how can i add the price column values and display as one record) ex. 222 17

table = table1

tep1 price (column)

222 5

222 2

222 10

SELECT SUM(price) FROM table1 WHERE tep1=222

Or

SELECT SUM(price) FROM table1 GROUP by tep1

The first will sum for just the 222 record, the second will sum for each unique tep1.

|||

SELECT tep1, SUM(price) AS "Total" FROM table1 GROUP BY tep1

No comments:

Post a Comment