0
大家好我已經在我的SQL SERVER中創建了2個表格,第一個表格叫做拍賣,第二個出價,每個拍賣都有一個狀態,它們可以是有效的,過期的或未售出的,當拍賣時沒有任何出價,但沒有任何出價,但過期時拍賣應該有一個或出價,問題是,我想選擇每個有出價的拍賣,並將其命名爲成功,並且所有拍賣的狀態未售出爲不成功Select Statement for 2 Tables
這裏是我的代碼
SELECT DATENAME(month, BID.Date) AS Years
,COUNT(DATENAME(Month, BID.Date)) AS Total
FROM Auction
INNER JOIN
BID ON Auction.AuctionID = BID.AuctionID
INNER JOIN
Item ON Auction.ItemID = Item.ItemID
WHERE (Auction.Status = 'Expired')
AND (BID.Status = 'Won')
GROUP BY DATENAME(month, BID.Date)
SELECT DATENAME(month, BID.Date) AS Years
, COUNT(DATENAME(Month, BID.Date)) AS Total
FROM Auction
INNER JOIN
BID ON Auction.AuctionID = BID.AuctionID
INNER JOIN
Item ON Auction.ItemID = Item.ItemID
WHERE (Auction.Status = 'UnSold')
GROUP BY DATENAME(month, BID.Date)
我想按日期組他們。
你並不遙遠,但如果我想有總韓元和總的未售出怎麼會請> – user3287068
就項目的數量銷往VS項目沒有賣?你所要做的就是重新查詢結果集的狀態分組。有多種方式。 –