I need help with an Acces Query vs. SQL Server Query

  • Thread starter Thread starter CLH
  • Start date Start date
C

CLH

I have a word document that has 'my Access query in SQL
view' and a 'SQL programmer's query not run through
Access' on it. Is someone willing to take a look at it
and help me see the light where I am going wrong with
matching the SQL direct? If so, please let me know so I
can send it as an attachment and not post it direct.

The only difference on mine to the SQL progmmr's is, a
DATEADD (day, 1, @ END DATE) where I do not have that in
mine. I am not getting the same count using my Access
query to the SQL direct one. I am 7 off here and 5 off
there yet right on count with others. Is there a command
in Access that would meet this exactly the same?

Thanks for any and all help.
 
Mine in Access SQL View


SELECT [tbl_Subscriptions]![sub_Newsletter_Code] AS [Sub Code], Count(tbl_Subscriptions.sub_Quantity) AS [Sum]
FROM tlkp_Subscription_Names INNER JOIN tbl_Subscriptions ON tlkp_Subscription_Names.sn_Abbrev = tbl_Subscriptions.sub_Newsletter_Code
WHERE (((tlkp_Subscription_Names.sn_Billing_Type)="r")) AND (((tbl_Subscriptions.sub_Subscr_Begin_Date) Between [Type Begin Date] And [Type End Date]))
GROUP BY [tbl_Subscriptions]![sub_Newsletter_Code], tlkp_Subscription_Names.sn_Billing_Type
ORDER BY [tbl_Subscriptions]![sub_Newsletter_Code];



Her’s in SQL Direct

SELECT s.sub_Newsletter_Code AS SubCode,
Sum(s.sub_Quantity) AS Quantity
FROM dbo.tlkp_Subscription_Names AS sc INNER JOIN dbo.tbl_Subscriptions AS s ON
sc.sn_Abbrev = s.sub_Newsletter_Code
WHERE sc.sn_Billing_Type='R' AND
s.sub_Subscr_Begin_Date >= @BeginDate AND
s.sub_Subscr_Begin_Date < DATEADD(day,1,@EndDate)
GROUP BY s.sub_Newsletter_Code
ORDER BY s.sub_Newsletter_Code
 
Back
Top