Hello all,
I'm not quite familiar with Select Case in SQL, but know it exists. I'm not sure, though, if it only exists for MS SQL Server alone, or if it can be used for MS Access as well. Does anyone know?
Also, I'm not positive on the format of it. Here are two that I've tried. The first:
which generates the following error when I try to save it:
Syntax error (missing operator) in query 'Case When [tblClients].[clientUseGroupAddress]=1 Then [tblGroups].[groupAddr1]'.
And the next thing I tried was:
Which generates the following error:
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (and then it highlights the word "When" when I hit the OK button.
Can anyone help?
-Ovatvvon :-Q
I'm not quite familiar with Select Case in SQL, but know it exists. I'm not sure, though, if it only exists for MS SQL Server alone, or if it can be used for MS Access as well. Does anyone know?
Also, I'm not positive on the format of it. Here are two that I've tried. The first:
Code:
SELECT
Case
When [tblClients].[clientUseGroupAddress]=1 Then [tblGroups].[groupAddr1] As listClientAddress
Else [tblClients].[clientAddr1] As listClientAddress
End
From tblGroups Right Join tblClients on [tblGroups].[groupPK]=[tblClients].[groupFK];
which generates the following error when I try to save it:
Syntax error (missing operator) in query 'Case When [tblClients].[clientUseGroupAddress]=1 Then [tblGroups].[groupAddr1]'.
And the next thing I tried was:
Code:
SELECT
Case ([tblClients].[clientUseGroupAddress]=1) As useGroupAddress
When useGroupAddress=1 Then ([tblGroups].[groupAddr1]) As listClientAddress
Else [tblClients].[clientAddr1] As listClientAddress
End Case
From tblGroups Right Join tblClients on [tblGroups].[groupPK]=[tblClients].[groupFK];
Which generates the following error:
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (and then it highlights the word "When" when I hit the OK button.
Can anyone help?
-Ovatvvon :-Q