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
Step: 1
When you run a GROUP BY query and have at least one column in the select list that is n...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started