473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

convert query from sql Server to A2K

These queries work in SQL Server but not in Access. Can anyone see how I can
modify these so they will work in A2K

SELECT A.AdId,
COUNT(DISTINCT I.ImpressionId) AS Impressions,
COUNT(DISTINCT C.ClickId) AS Clicks
FROM tblAds A
LEFT JOIN tblImpressions I ON I.AdId = A.AdId
LEFT JOIN tblClicks C ON C.AdId = A.AdId
GROUP BY A.AdId

I understand Access doesn't have Count Distinct functionality but what about
the next query.

select
a.AdId
, isnull (i.Impressions, 0) Impressions
, isnull (c.Clicks, 0) Clicks
from
tblAds a
left join
(
select
AdId
, count (*) as Impressions
from
tblImpressions
group by
AdId
) i on i.AdId = a.AdId
left join
(
select
AdId
, count (*) as Clicks
from
tblClicks
group by
AdId
) c on c.AdId = a.AdId

Thanks to anyone who could help
Nov 13 '05 #1
1 1434
Ed
Terri:

Try this query:

SELECT a.AdId, nz([c].[NumClicks],0) AS Clicks, nz([i].[NumImpressions],0)
AS Impressions
FROM (tblAds AS a LEFT JOIN (SELECT tblClicks.AdId, Count(tblClicks.ClickID)
AS NumClicks
FROM tblClicks
GROUP BY tblClicks.AdId) AS c ON a.AdId = c.AdId) LEFT JOIN (SELECT
tblImpressions.AdId, Count(tblImpressions.ImpressionID) AS NumImpressions
FROM tblImpressions
GROUP BY tblImpressions.AdId) AS i ON a.AdId = i.AdId;

Note that the tablename prefixes for the fieldnames needed to be included in
the subqueries. Also, I used a different alias for the subqueries than you
did.

Good luck,
Ed

"Terri" <te***@cybernets.com> wrote in message
news:cl**********@reader2.nmix.net...
These queries work in SQL Server but not in Access. Can anyone see how I can modify these so they will work in A2K

SELECT A.AdId,
COUNT(DISTINCT I.ImpressionId) AS Impressions,
COUNT(DISTINCT C.ClickId) AS Clicks
FROM tblAds A
LEFT JOIN tblImpressions I ON I.AdId = A.AdId
LEFT JOIN tblClicks C ON C.AdId = A.AdId
GROUP BY A.AdId

I understand Access doesn't have Count Distinct functionality but what about the next query.

select
a.AdId
, isnull (i.Impressions, 0) Impressions
, isnull (c.Clicks, 0) Clicks
from
tblAds a
left join
(
select
AdId
, count (*) as Impressions
from
tblImpressions
group by
AdId
) i on i.AdId = a.AdId
left join
(
select
AdId
, count (*) as Clicks
from
tblClicks
group by
AdId
) c on c.AdId = a.AdId

Thanks to anyone who could help

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ian m via SQLMonster.com | last post by:
Hi, I currently have a ms access update query that runs perfectly well and quicly in access however I now need to add this query to convert this qeryu to oracles equivelant sql syntax and add it...
1
by: gpaille | last post by:
I got a big Access database I'd like to convert to MS SQL Server 2000 and I'm looking for an efficient automated tool to convert data (over 1 400 tables), query, forms and interface. Does...
4
by: Guy | last post by:
I got a big Access file (1 400 tables) to convert to SQL and I would like to be provided with some automated tools, except upsizing wizard and DTS, to convert it on my own. I got a lot of forms...
29
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them...
8
by: Assimalyst | last post by:
Hi i have a value entered into an asp text box, procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
5
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
I am having a problem converting string to binary and I am hoping someone can help me out I have a sql query that does an update that updates a binary field calles password ...
3
by: Kunal Desale | last post by:
Hello, I am migrating access queries to SQL Server 2005 Queries. My Access Query Is: SELECT qtrade.intordreftrim AS Expr1, qtrade.extordreftrim AS Expr2, qtrade.intinvreftrim AS Expr3,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.