In general, if you're experiencing an error it is highly helpful, encouraged even to post what the error is. I'll assume you are seeing a message about "Column 'pagetab.code' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."To resolve this, you are most likely interested in SELECT PT.code, PT.id, PT.pageno, PT.price, sum(PT.price) AS totalFROM pagetab PTGROUP BY PT.code, PT.id, PT.pageno, PT.price
I'm not sure about your where clause, that should give you no results unless you have a join that you did not show.