I have data like:
key value
k1 string1
k2 Other string
k3 Long string
k1
k3 string
Some of them could be empty.
I want to return longest value if key is duplicated. So the result should be like:
key value
k1 string1
k2 Other string
k3 Long string
My code (with solving memo field aggregating):
"IIF(COUNT(key)=1, " & _
"MAX(IIF(LEN(value)>250, " & _
"'[CUT]' & LEFT(value, 245), " & _
value & "))," & _
"MAX(IIF(LEN(value)>250, " & _
"'[[CUT]' & LEFT(value, 245) & ']', " & _
"'[' & value & ']' ))) AS " & value
The thing is that I want to return longest string from duplicates. Now I use MAX function but this return value due to alphabetical order so if value is empty it returns empty.
I am getting data using ADODB with
[Excel 12.0;Provider=Microsoft.ACE.OLEDB.12.0;Mode=Read;Extended Properties=IMEX=1;TypeGuessRows=1;ImportMixedTypes=Text'HDR=YES;']