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

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

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

When you run a GROUP BY query and have at least one column in the select list that is n... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!