sql server query to create an access query that will only result in 1 distinct combination

Access: 2010
What I have:   sql server query that creates a unique


What I need:
I need to create a query that will find distinct and unique combination of 2 fields

Current sql server query:  I NEED THIS QUERY TO RESULT THE SAME IN ACCESS


SELECT MIN(SKU) AS SKU
       ,[CompSKUCondensed]
       ,[VdrBrandName]
       ,COUNT([sku]) AS [Count]
   FROM [QA].[dbo].[comp_aio_bkp_vsm]
   WHERE SKU > '' and [CompSKUCondensed] > '' and [VdrBrandName] > '' and
         XRef_Comment NOT IN ('PARENT CHILD CROSSES', 'BRAND XREFS FROM 1 TO 16','BRAND FROM 1 TO 16')
   GROUP BY  
        [VdrBrandName]
   ,[CompSKUCondensed]
   HAVING COUNT(SKU) = 1
   ORDER BY [CompSKUCondensed]


Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin SparksCommented:
What you have there is fairly close to what you'd need. The WHERE statement will need some work I suspect, but not sure what you're trying to achieve with that.


Kelvin
0
PortletPaulfreelancerCommented:
SELECT
      MIN( SKU ) AS SKU
    , [CompSKUCondensed]
    , [VdrBrandName]
    , COUNT( [sku] ) AS [CountOf]
FROM your_table_here
WHERE (SKU > '')
AND ([CompSKUCondensed] > '')
AND ([VdrBrandName] > '')
AND (XRef_Comment NOT IN ('PARENT CHILD CROSSES', 'BRAND XREFS FROM 1 TO 16', 'BRAND FROM 1 TO 16'))
GROUP BY
         [VdrBrandName]
       , [CompSKUCondensed]
HAVING COUNT( SKU ) = 1
ORDER BY [CompSKUCondensed]

Open in new window


Access seems likes parentheses which can be painful (IMO) but aside from the table name the query looks as if it will work pretty much as is

In SQL Server you can use that having clause without including that column in the select clause, not sure about Access.

COUNT(SKU) as [Count] -- I don't recommend using reserved words so I used [CountOf]
&
you could use COUNT(*) for the same calculation

or, you might be after COUNT( DISTINCT SKU ) perhaps?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FordraidersAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.