0

所以我有以下内容:

SELECT 
    data, 
    encrypteddata,
    CONVERT(varchar, DecryptByKey(encrypteddata)) AS 'decrypteddata'
FROM table

给定密钥,它将原始数据列、加密数据列和解密数据列输出为临时列。都好。

我一直在尝试做的是得到那个结果,然后再做一个 AS 列,然后Match用真假来判断它是否匹配。

我试过了

SELECT 
    data, 
    encrypteddata,
    CONVERT(varchar, DecryptByKey(encrypteddata)) AS 'decrypteddata'
    COUNT(distinct(decrypteddata))
FROM table
WHERE COUNT (distinct(decrypteddata)) > 1 
GROUP BY data

这只是给我一个COUNT关于语法的错误。

有没有人建议我如何做到这一点?

4

2 回答 2

0

我看到您在此行末尾缺少一个冒号

CONVERT(varchar, DecryptByKey(encrypteddata)) AS 'decrypteddata'

另外,我不太明白你想匹配什么,但考虑使用 IF

SELECT
IF(CONVERT(varchar, DecryptByKey(encrypteddata))=other_data_field, 'true','false') as Match
....
于 2012-07-28T02:05:05.837 回答
0

试试这个

SELECT 
data, 
encrypteddata,
CONVERT(varchar, DecryptByKey(encrypteddata)) AS 'decrypteddata',
COUNT(distinct(decrypteddata))
FROM table
WHERE COUNT (distinct(decrypteddata)) >1 group by data

--Here you have used convert function-In this you have used just varchar without length parameter.So if you actual data is of more than 30 characters it will take only 30 characters and rest will be truncated.So just make sure what would be the length of your actual data.

于 2012-07-28T05:46:09.253 回答