I get the followng error: Msg 8120, Level 16, State 1, Line 93 Column 'buyer.buyerID' is invalid
Question:
I get the followng error:
Msg 8120, Level 16, State 1, Line 93
Column 'buyer.buyerID' is invalid in the select list because it isnot contained in either an aggregate function or the GROUP BYclause.
for this query:
SELECT buyerID, buyerName FROM buyer AS a
INNER JOIN buyerItem AS b ON buyer_ID = buyerID
GROUP BY buyer_ID ORDER BY COUNT(item_ID) DESC SET ROWCOUNT1;
WHAT IM TRYING TO DO The most activebuyer (the one who has bought the most number of items)
MY tables:
create table buyer
(
buyerID INT IDENTITY(1000,1) NOT NULL,
buyerName varchar(20) NOTNULL,
buyerUsername varchar(20)UNIQUE NOT NULL,
buyerPassowrd varchar(32) NOT NULL,
contact_ID int,
creditCardID int,
primary key(buyerID),
Foreign Key(contact_ID) referencescontactInfo(contactID),
Foreign Key(creditCardID) referencescreditCardInfo(credit_CardID));
create table buyerItem
(
buyer_ID int NOT NULL,
item_ID int NOTNULL,
PRIMARY KEY(buyer_ID,item_ID),
FOREIGN KEY (buyer_ID) REFERENCESbuyer(buyerID),
FOREIGN KEY (item_ID) REFERENCES item(itemID));
LET ME KNOW IF YOU NEED MORE INFORMATION
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill