Finding A Distinct count in a certain time period

I need help with a SQL question in how to build the script. The question is asking how many bidders a company had in October?

So far I have:
SELECT count (distinct bidder_id)
FROM misc.abc_bids
WHERE auction_date

Auction_date is the table with the dates
misc.abc_bids is the database
bidder_id is each specific bidder

Are you taking a course or is this a part of a test or an interview question?

FROM misc.abc_bids
WHERE DATE_TRUNC('month', auction_date) = '2022-10-01'

Or use a DATEADD instead of DATE_TRUNC.

In the case of that code, let's hope the OP is using SQL Server 2022.

1 Like