GRose
Registered User.
- Local time
- Today, 09:23
- Joined
- Mar 4, 2004
- Messages
- 21
Hello all.
Just noticed I haven't posted in here since 2006, I was amazed I could still log in!
I have a query which uses the same table 3 times, the aliases all appear ok and if I run it via SQL Management Studio, I get the expected results.
The code is as below:
What is happening is that I get no data for OptionB or OptionC but as I stated, if I run it via SQL MS, it works fine.
I tried using [ and ] around the aliases just in case but it made no difference so what is going on?
Just noticed I haven't posted in here since 2006, I was amazed I could still log in!
I have a query which uses the same table 3 times, the aliases all appear ok and if I run it via SQL Management Studio, I get the expected results.
The code is as below:
Code:
SELECT
dbo_SROrganisation.Name,
dbo_SR18WeekWait.DateCompleted,
dbo_SR18WeekWait.TreatmentFunction,
A.ConfiguredListOption AS OptionA,
dbo_SR18WeekWait.Status,
B.ConfiguredListOption AS OptionB,
dbo_SRReferralIn.ServiceOffered,
C.ConfiguredListOption AS OptionC
FROM
((((dbo_SRReferralIn RIGHT JOIN dbo_SR18WeekWait ON dbo_SRReferralIn.RowIdentifier = dbo_SR18WeekWait.IDReferralIn)
LEFT JOIN dbo_SRConfiguredListOption AS A ON dbo_SR18WeekWait.TreatmentFunction = A.RowIdentifier)
LEFT JOIN dbo_SRConfiguredListOption AS B ON dbo_SR18WeekWait.Status = B.RowIdentifier)
LEFT JOIN dbo_SRConfiguredListOption AS C ON dbo_SRReferralIn.ServiceOffered = C.RowIdentifier)
INNER JOIN dbo_SROrganisation ON dbo_SR18WeekWait.IDOrganisationVisibleTo = dbo_SROrganisation.ID
GROUP BY
dbo_SROrganisation.Name,
dbo_SR18WeekWait.DateCompleted,
dbo_SR18WeekWait.TreatmentFunction,
A.ConfiguredListOption,
dbo_SR18WeekWait.Status,
B.ConfiguredListOption,
dbo_SRReferralIn.ServiceOffered,
C.ConfiguredListOption
HAVING
(((dbo_SROrganisation.Name)="GROrg1")
AND
((dbo_SR18WeekWait.DateCompleted) Between #12/1/2016# And #12/31/2016#));
What is happening is that I get no data for OptionB or OptionC but as I stated, if I run it via SQL MS, it works fine.
I tried using [ and ] around the aliases just in case but it made no difference so what is going on?