Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

orderby clause with primery key

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi

i select a number of column, one of which is sum. so i need to use group by clause. at simple logic primery key should be enough, but it gives error so need to print all column name in group by clause
Code:
SELECT trader.name, trader.surname, trader.bagkur_no, trader.father_name, 
trader.birth_place, DATEPART( yyyy, trader.birth_date) AS birth_year, 
trader.address, sum( amount) AS amount
FROM purchase
INNER JOIN trader ON purchase.producer_id = trader.id
GROUP BY trader.id, trader.name, trader.surname, trader.bagkur_no, trader.father_name, 
trader.birth_place, DATEPART( yyyy, trader.birth_date), trader.address
ORDER BY trader.id

i think trader.id (primery key ) should be enough.

but it does not.

is there any way
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top