SQL Max Group By Query Help
- by Hcabnettek
Hi All,
I have a quick question. How do I select the two values I need in one query? Currently I'm doing this, which works fine, but it's obviously running two queries when one should do the trick. I tried MAX(columnA) and GROUP BY ColumnB, but that returns multiple row. I only want one row returned.
DECLARE @biID bigint
, @dtThreshold DateTime
SELECT @biID = MAX(biID)
FROM tbPricingCalculationCount WITH (NOLOCK)
SELECT @dtThreshold = dtDateTime
FROM tbPricingCalculationCount WITH (NOLOCK)
WHERE biID = @biID
I would like both those variables to be set correctly in one query. How can I do that?
Thanks,
~ck