0

I have 82425 data in a table. through a query I fetched 73876 data in a new table. Now I want the data which I have not got from the query. My query is

SELECT  af.* Into IAGroupNoNGroup
FROM
    (
        SELECT  Key_out, MAX(Max_FieldValue) Max_FieldValue, 
        (
            SELECT  TOP 1 Key_in 
            FROM    dbo.IASubcriberFuzzy1 b 
            WHERE   b.Max_FieldValue = MAX(a.Max_FieldValue) 
                            AND b.Key_out = a.Key_out
        ) Key_In
        FROM    IASubcriberFuzzy1 a
        WHERE   a.Key_out IN 
                (
                    SELECT  Key_out 
                    FROM    IASubcriberFuzzy1
                    GROUP BY Key_out
                    HAVING  COUNT(Key_out) > 1
                )
        GROUP BY a.Key_out
    ) mxv LEFT OUTER JOIN IASubcriberFuzzy1 af
    ON (mxv.Key_In = af.Key_in
        AND mxv.Key_out = af.Key_out
        AND mxv.Max_FieldValue = af.Max_FieldValue)

UNION ALL

SELECT  af.*
FROM    IASubcriberFuzzy1 af
WHERE   af.Key_out IN 
        (
            SELECT  Key_out 
            FROM    IASubcriberFuzzy1
            GROUP BY Key_out
            HAVING  COUNT(Key_out) = 1
        ) 

Please Help!!

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by debasisdas
0

try something like this.

select * from IASubcriberFuzzy1 where priamry_key in
(select priamry_key from IASubcriberFuzzy1
minus
select priamry_key from (your query goes here))

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.