views:

58

answers:

2

i have one question. I have a accttype (varchar) field in t_data table. I have different length acct numbers in that field. like few are 15 digit and few are 13 digit. 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.

can any one write sql query for that.Please. Its urgent.

+1  A: 

This is SQL Server syntax but should be about the same for Oracle:

select len(accttype), count(*) 
from t_data 
group by len(accttype) 
order by 1
ck
+2  A: 

For the list

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

and to list them seperatly for 13

SELECT accttype
FROM T_DATA 
WHERE LEN(accttype) = 13

and for 15

SELECT accttype
FROM T_DATA 
WHERE LEN(accttype) = 15
kevchadders
LEN() is SQL Server (I suppose). The Oracle function is LENGTH()
David Aldridge
Good spot... keep getting the syntax mixed up between the two...
kevchadders