简体   繁体   English

sql server问题

[英]sql server questions

i have one question. 我有一个问题。 I have a accttype (varchar) field in t_data table. 我在t_data表中有一个accttype(varchar)字段。 I have different length acct numbers in that field. 我在该字段中有不同的长度acct数字。 like few are 15 digit and few are 13 digit. 像是15位数字和13位数字一样。 I just want to know how many are there 13 digit acct no and how many are there 15 digit acct number and list them separately. 我只想知道有多少个13位数的帐号,有多少个15位数的帐号,然后分别列出。

can any one write sql query for that.Please. 任何人都可以为此编写SQL查询。 Its urgent. 这非常紧急。

For the list 对于列表

SELECT LEN(accttype), COUNT(*) 
FROM T_DATA 
GROUP BY LEN(accttype) 
ORDER BY 1

and to list them seperatly for 13 并分别列出13

SELECT accttype
FROM T_DATA 
WHERE LEN(accttype) = 13

and for 15 和15

SELECT accttype
FROM T_DATA 
WHERE LEN(accttype) = 15

This is SQL Server syntax but should be about the same for Oracle: 这是SQL Server语法,但对于Oracle应该大致相同:

select len(accttype), count(*) 
from t_data 
group by len(accttype) 
order by 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM