oracle中字元串統計的函數以下文字資料是由(曆史新知網www.lishixinzhi.com)小編為大家搜集整理後釋出的内容,讓我們趕快一起來看一下吧!
oracle中字元串統計的函數
統計總數的函數:count();篩選特定字元的方法是:like。
sql:select count(*) from tablename where name like '%特定字元%'。
上面語句的意思就是:篩選出表字段内容中帶有“特定字元”行數的總數。
編寫函數,統計字元串中字母,數字,空格和其他字元的個數,要求在主函數中輸入字元串,并輸入統計的結果
C++:
#i nclude
int letter,digit,space,others;
void main()
{
void count(char[]);
char text[80];
printf("輸入字元串:\n");
gets(text);
printf("字元串是:");
puts(text);
letter=0;
digit=0;
space=0;
others=0;
count(text);
printf("letter:%d,digit:%d,space:%d,others:%d\n",letter,digit,space,others);
}
void count(char str[])
{int i;
for(i=0;str[i]!='\0';i++)
if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))
letter++;
else if(str[i]>='0'&&str[i]<='9')
digit++;
else if(str[i]==32)
space++;
else
others++;
}
C語言統計字元串中字元個數,不用庫函數
#include
int count_letter(char *str)
{
char *p = str;
int t = 0;
開始計數
while (*p != '\0') {
if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) {
t++;
}
p++;
}
計數完成
printf("letter t:%d\n", t); 列印出英文字母總數
return t; 計數結果傳回
}
int main()
{
char *str = "gkdial9-1.;J19D-=-=YdlUImf"; 執行個體字元串
count_letter(str); 調用計數函數
return 0;
}
以上源碼。
主要思路為循環到字元串結尾,逐字元判斷是否屬于字母範圍(A到Z或a到z),如果為字母則計數器+1,直到字元為結束符'\0'為止,表示字元串結束,并将結果傳回給函數調用者。
編一函數統計一個字元串中字元t的個數
int find_t( char *str)
{
int i=0;
while(*str)
{
if ( *str=='t' ) i++;
str++;
}
return i ;
}
sas中統計字元串中字元個數
#include #include int main(){ char sLine[1024] = ""; scanf("%s",sLine); std::map mapCount; for(int i=0;sLine[i]!=0;i++){ mapCount[sLine[i]]++; } std::map::iterator it = mapCount.begin(); for(;it!=mapCount.end();it++) { printf("%c is %d\n",it->first,it->second); } return 0;}
sql統計的特定字元串出現次數
select t2.vf,
D1=count(case when t1.D1 like '%'+t2.vf+'%' then 1 else null end),
D2=count(case when t1.D2 like '%'+t2.vf+'%' then 1 else null end),
D3=count(case when t1.D3 like '%'+t2.vf+'%' then 1 else null end) from table1 t1,(select vf='W' union select 'S' union select 'Q') t2
group by t2.vf
這樣清楚點。
vf D1 D2 D3
----------------------------------------
Q 2 1 3
S 2 2 2
W 2 1 1
excel中字元串函數
方法一
選中資料所在的單元格區域(隻能是一列内的區域,如果邊一列有内容則先插入兩個新列)---資料---分列---分隔符号--- 勾選"其他",輸入"/"符号---下一步---完成.
如果中間一列想在加上"/"可再其後插入新列 用公式(假設是B列) ="/"&B1&"/" 下拉複制公式,複制得出的值---右鍵---選擇性粘貼---數值,再删去B列
方法二
用公式,假設該資料在A列
B1輸入公式
=LEFT(A1,FIND("/",A1)-1)
下拉複制公式
C1單元格輸入公式
=MID(A1,FIND("/",A1),FIND("/",A1,FIND("/",A1)+1)-FIND("/",A1)-1)
下拉複制公式
D1單元格輸入公式
=RIGHT(A1,LEN(A1)-FIND("/",A1,FIND("/",A1)+1)-1)
下拉複制公式
asp中字元串函數
inform = "23/43"
arr = split(infrom, "/")
response.write arr(0) & "
" & arr(1)
求SQL 按分組拆分字元串并統計的自定義函數
SELECT SUBSTR(地區,1,3) AS 地區,
SUM(面積)AS 面積
COUNT(SUBSTR(地區,1,3))AS 個數
FROM 地區面積表
GROUP BY SUBSTR(地區,1,3)
vf中字元串比對函數 like(字元串1,字元串2)含義?
确定一個字元表達式是否與另一個字元表達式相比對。
LIKE(cExpression1, cExpression2)
參數
cExpression1
指定要在 LIKE( ) 中與 cExpression2 相比較的字元表達式。cExpression1 中可以包含通配符 * 和 ?。問号 (?) 可與 cExpression2 中的任何單個字元相比對,星号 (*) 可與任意數目的字元相比對。在 cExpression1 中可以把任何數目的通配符進行任意的組合。
cExpression2
指定要在 LIKE( ) 中與 cExprssion1 相比較的字元表達式。隻有在 cExpression1 與 cExpression2 中的字元逐個比對的情況下, LIKE( ) 函數才傳回“真”(.T.)。
傳回值
邏輯型
說明
如果 cExpression1 與 cExpression2 相比對,則 LIKE( ) 函數傳回“真”(.T.);否則,傳回“假”(.F.)。
SET COMPATIBLE 決定 LIKE( ) 函數如何比較 cExpression1 和 cExpression2 中的空格。若 SET COMPATIBLE 設定為 ON 或 DB4,則在比較之前删除 cExpression1 和 cExpression2 中的字尾空格。若 SET COMPATIBLE 設定為 OFF 或 FOXPLUS,則 cExpression1 和 cExpression2 的字尾空格也參加比較。
示例
下面的示例将顯示 products 表中所有前兩個字元是“Ch”的産品名。I
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE products && Open Products table
CLEAR
? 'All product names with first o letters Ch:'
?
SCAN FOR LIKE('Ch*', prod_name)
? prod_name
ENDSCAN
USE
分頁:123