SQL_Enthusiast (1/29/2013)
Does that help?
I... think so.
Tell me if this does basically what you're looking for, and where, if anywhere, it goes awry:
DECLARE @CHG_ITEM TABLE(
CHARGE_BATCH_ID int,
CHARGE_ITEM_IDint,
REVENUE_SITE_IDint)
INSERT INTO @CHG_ITEM(CHARGE_BATCH_ID, CHARGE_ITEM_ID, REVENUE_SITE_ID)
VALUES
(1, 15929, 1000),
(1, 16930, 1000),
(10, 17186, 2000),
(10, 18187, 5000),
(10, 22188,2000),
(22, 14189, 3000),
(22, 21190,3000),
(22, 20191,3000),
(100, 30282, 4000),
(100, 30283, 4000),
(100, 11284, 4000);
SELECT
CHARGE_BATCH_ID
FROM
(SELECT DISTINCT
CHARGE_BATCH_ID,
REVENUE_SITE_ID
FROM
@CHG_ITEM
WHERE
CHARGE_BATCH_ID IS NOT NULL
) AS drv
GROUP BY
CHARGE_BATCH_ID
HAVING
COUNT(*) > 1
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA