# 1055 - Выражение № 19 списка SELECT отсутствует в предложении GROUP BY и содержит неагрегированный столбец - PullRequest
0 голосов
/ 04 декабря 2018

У меня есть эта ошибка, отображаемая в моем запросе sql:

"Выражение # 19 списка SELECT отсутствует в предложении GROUP BY и содержит неагрегированный столбец 'auctionystems.auction_watches.watchId', который не является функциональнов зависимости от столбцов в предложении GROUP BY, это несовместимо с sql_mode = only_full_group_byDatabase запрос выбора не выполнен. "

Я пытался получить количество аукционов, которые пользователь просматривает, из списка аукционов, но когдаПользователь выбрал несколько аукционов, чтобы посмотреть ошибки.Может кто-нибудь сказать мне, что не так с запросом:

SELECT auctions.auctionId, quantity, startPrice, reservePrice, startTime,
        endTime, itemName, itemBrand, itemDescription, items.image, auctions.views,
        item_categories.categoryName as subCategoryName, superCategoryName,
        item_categories.superCategoryId, item_categories.categoryId, users.username as sellerUsername,
        conditionName, countryName, auction_watches.watchId, COUNT(DISTINCT (bids.bidId)) AS numBids,
        MAX(bids.bidPrice) AS highestBid,
        case
            when MAX(bids.bidPrice)is not null THEN MAX(bids.bidPrice)
            else startPrice
        end as currentPrice,
        case
            when MAX(bids.bidPrice) > auctions.reservePrice AND auctions.endTime < now() then 1
            else 0
        end as sold


        FROM auctions
            LEFT OUTER JOIN bids ON bids.auctionId = auctions.auctionId
            JOIN auction_watches ON auction_watches.auctionId = auctions.auctionId
            JOIN items ON items.itemId = auctions.itemId
            JOIN users ON items.userId = users.userId
            JOIN item_categories ON items.categoryId = item_categories.categoryId
            JOIN super_item_categories ON  item_categories.superCategoryId = super_item_categories.superCategoryId
            JOIN item_conditions ON items.conditionId = item_conditions.conditionId
            JOIN countries ON users.countryId = countries.countryId

        WHERE auction_watches.watchId IN( 19706, 19707 )

        GROUP BY auctions.auctionId

        ORDER BY CASE WHEN auctions.endTime > now() THEN 0 ELSE 1 END ASC, auctions.endTime ASC

1 Ответ

0 голосов
/ 04 декабря 2018

Вам нужно добавить все остальные столбцы, кроме агрегированных столбцов, в группу по пункту

SELECT auctions.auctionId, quantity, startPrice, reservePrice, startTime,
        endTime, itemName, itemBrand, itemDescription, items.image, auctions.views,
        item_categories.categoryName as subCategoryName, superCategoryName,
        item_categories.superCategoryId, item_categories.categoryId, users.username as sellerUsername,
        conditionName, countryName, auction_watches.watchId, COUNT(DISTINCT (bids.bidId)) AS numBids,
        MAX(bids.bidPrice) AS highestBid,
        case
            when MAX(bids.bidPrice)is not null THEN MAX(bids.bidPrice)
            else startPrice
        end as currentPrice,
        case
            when MAX(bids.bidPrice) > auctions.reservePrice AND auctions.endTime < now() then 1
            else 0
        end as sold


        FROM auctions
            LEFT OUTER JOIN bids ON bids.auctionId = auctions.auctionId
            JOIN auction_watches ON auction_watches.auctionId = auctions.auctionId
            JOIN items ON items.itemId = auctions.itemId
            JOIN users ON items.userId = users.userId
            JOIN item_categories ON items.categoryId = item_categories.categoryId
            JOIN super_item_categories ON  item_categories.superCategoryId = super_item_categories.superCategoryId
            JOIN item_conditions ON items.conditionId = item_conditions.conditionId
            JOIN countries ON users.countryId = countries.countryId

        WHERE auction_watches.watchId IN( 19706, 19707 )

        GROUP BY auctions.auctionId, quantity, startPrice, reservePrice, startTime,
        endTime, itemName, itemBrand, itemDescription, items.image, auctions.views,
        item_categories.categoryName as subCategoryName, superCategoryName,
        item_categories.superCategoryId, item_categories.categoryId, users.username as sellerUsername,
        conditionName, countryName, auction_watches.watchId

        ORDER BY CASE WHEN auctions.endTime > now() THEN 0 ELSE 1 END ASC, auctions.endTime ASC
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...