我是靠谱客的博主 俊秀树叶,这篇文章主要介绍一句SQL,判断char列的值是否组成回文字符串,现在分享给大家,希望可以做个参考。

Table t has 2 columns:
id INT;
value CHAR(1);
Column id starts from 0, increased by 1 each row
Column value is a single character string
Table t has at least 1 row
String s is a palindrome when:
s[i] = s[s.length - i - 1] for i = 0 … (s.length – 1) / 2
E.g.: a, aba, abba.
Q: Write one SQL statement to check if the string composed of value of t ordered by id is a palindrome (case sensitive).
Output “Y” or “N”.
这里写图片描述

with tmp as 
(
    (select (select count(1) from t1)-1-id as id,value from t1)
except
    (select id,value from t1)
)
select 
case when count(1)=0 
then 'Y' else 'N' end 
from tmp;

最后

以上就是俊秀树叶最近收集整理的关于一句SQL,判断char列的值是否组成回文字符串的全部内容,更多相关一句SQL,判断char列内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(132)

评论列表共有 0 条评论

立即
投稿
返回
顶部