Hi,
I need to create a SQL query.
I have two tables where I need to retreive data and create a NEW field
within the QUERY and then export.
Table 1 and 2 are linked by the same ID reference
The first OUTPUT is 'Model' from Table 1 (LDDBService.Table1).
The second OUTPUT (a NEW field - Let's call it '
NewAdd') depends on the existing value from an 'Address' field in Table 2. I'm using a SubString, but I'm not sure this is correct.
Code:
SUBSTRING(LDDBService.Table2.Address, 9, 3)
Where, for Example
If Table2.Address is '
xxx.xxx.104.xxx'
I need to return "
AA"
Can/should I use an IF statement similar to this?
Code:
IIF(SUBSTRING(LDDBService.Table2.Address, 9, 3)='104', "AA", IIF(SUBSTRING(LDDBService.Table2.Address, 9, 3)='105', "BB", IIF(SUBSTRING(LDDBService.Table2.Address, 9, 3)='106', "CC" "")))
If not, what should I be doing?
Then I need to Count on the number of occurences of "AA", "BB", "CC" etc.
Please can someone show me how I:
1.
Create these values in the NEWADD field
2.
Count the Occurence of each NEWADD value
3.
Export the data (Crystal Report or .csv)
Thanks in advance,
Neal
A Northern Soul