求一个SQL语句,达人帮帮忙了,在线等
SELECT 缴款人账号
FROM zh331
GROUP BY 缴款人账号
HAVING COUNT(SUBSTRING(缴款人账号, 2, 5)) > = 2
求缴款人账号从第二位开始到第六位的数字重复数大于等于2的,上面的是错的,只是为了跟大家表述清楚,达人帮忙了,在线等,急!
[解决办法]
SELECT SUBSTRING(缴款人账号, 2, 5)
FROM zh331
GROUP BY SUBSTRING(缴款人账号, 2, 5)
HAVING COUNT(*)> = 2
有问题再说!
[解决办法]
SELECT 缴款人账号
FROM (
SELECT 缴款人账号,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '0 ' || SUBSTRING(缴款人账号, 2, 5), '0 '), NULL, 0, 0, 0, 1, 0, 1) AS ZERO,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '1 ' || SUBSTRING(缴款人账号, 2, 5), '1 '), NULL, 0, 0, 0, 1, 0, 1) AS ONE,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '2 ' || SUBSTRING(缴款人账号, 2, 5), '2 '), NULL, 0, 0, 0, 1, 0, 1) AS TWO,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '3 ' || SUBSTRING(缴款人账号, 2, 5), '3 '), NULL, 0, 0, 0, 1, 0, 1) AS THREE,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '4 ' || SUBSTRING(缴款人账号, 2, 5), '4 '), NULL, 0, 0, 0, 1, 0, 1) AS FOUR,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '5 ' || SUBSTRING(缴款人账号, 2, 5), '5 '), NULL, 0, 0, 0, 1, 0, 1) AS FIVE,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '6 ' || SUBSTRING(缴款人账号, 2, 5), '6 '), NULL, 0, 0, 0, 1, 0, 1) AS SIX,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '7 ' || SUBSTRING(缴款人账号, 2, 5), '7 '), NULL, 0, 0, 0, 1, 0, 1) AS SEVEN,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '8 ' || SUBSTRING(缴款人账号, 2, 5), '8 '), NULL, 0, 0, 0, 1, 0, 1) AS EIGHT,
DECODE(TRANSLATE(SUBSTRING(缴款人账号, 2, 5), '9 ' || SUBSTRING(缴款人账号, 2, 5), '9 '), NULL, 0, 0, 0, 1, 0, 1) AS NINE
FROM zh331
)
WHERE ZERO + ONE + TWO + THREE + FOUR + FIVE + SIX + SEVEN + EIGHT + NINE > 0
不知道我猜到你想要的结果了没有
[解决办法]