How to count a number in number using sql query
Hi Guys,
I want to count a number in number.please answer this query.
eg> i have a phone No : 9988585633
Now i want to count a number of this phone no:
if i will give no: 9 then it will return 2
if i will give no: 8 ,tnen it will return 3.
regards,
Dhanush
Something like this:
$[CHE_TEST@asterix1_impl] var phoneno char(10);
$[CHE_TEST@asterix1_impl] exec :phoneno := '9988585633';
PL/SQL procedure successfully completed.
$[CHE_TEST@asterix1_impl] ed
Wrote file c:\temp\afiedt.sql
1 with data as (
2 select substr(:phoneno, level, 1) no
3 from dual connect by level <= length(:phoneno)
4 )
5 select count(*), no
6 from data
7* group by no
$[CHE_TEST@asterix1_impl] r
1 with data as (
2 select substr(:phoneno, level, 1) no
3 from dual connect by level <= length(:phoneno)
4 )
5 select count(*), no
6 from data
7* group by no
COUNT(*)|N
----------|-
2|3
1|6
3|8
2|5
2|9cheers
Similar Messages
-
How to get AD reconciliation event data using SQL query.
Hi All,
I was trying to get all recon data for Target AD Recon from OIM db, but it seems that in OIM 11g we do not have recon data in tables: RCU, RCE, etc. We have to use "RECON_..." tables, my question is does any bady has sample query to fetch data from recon tables?
best
mpIt should be a question of linking your AD user reconciliation table (beginning RA_) with the RECON_EVENTS table by RE_KEY.
In my case I have OID user reconciliation (so my RA_ table will be different to yours) and can use something like:
SELECT RECON_EVENTS.RE_STATUS, RA_OIDUSER5.* FROM RECON_EVENTS, RA_OIDUSER5 WHERE RECON_EVENTS.RE_KEY = RA_OIDUSER5.RE_KEY;
Obviously it then depends on what information you want to filter on and retrieve. -
How do count how many 'A' s in this string using sql stmt?
hi all,
i have a string like 'AAAAARAMAAAAKRISHNAAAA'.
in this ,i want to find out how many 'A's .
how do find out this using select stmt.(length(s) - nvl(length(replace(s, 'A')), 0)) / length('A')but consider (by modifying the question slightly to "how do count how many 'AA' s in this string using sql stmt? ")
SQL> select (length('AAAAARAMAAAAKRISHNAAAA') - nvl(length(replace('AAAAARAMAAAAKRISHNAAAA', 'AA')), 0)) / length('AA') x from dual
X
6
1 row selected.couldn't I argue that the result should be 10 as e.g. in
SQL> select * from xmltable('let $str := "AAAAARAMAAAAKRISHNAAAA"
let $search := "AA"
for $i in 1 to string-length($str)
where substring($str, $i, string-length($search)) = $search
return substring($str, $i, string-length($search))' columns x varchar2(10) path '.')
X
AA
AA
AA
AA
AA
AA
AA
AA
AA
AA
10 rows selected.Matter of definition I suppose .... ;)
btw. regexp_count also yields 6:
SQL> select regexp_count('AAAAARAMAAAAKRISHNAAAA', 'AA') x from dual
X
6
1 row selected. -
How to get tax break up of TDS using SQL query ?
Hi all,
We are developing a TDS report using SQL query
Report will contain VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount,
Bill Value 100.000,
TDS (2%) - 2.000,
TDS Surcharge(10% on TDS) - 0.2,
TDS Cess(2%(TDS+TDS Surcharge)) - 0.044,
TDS HeCess(1%(TDS+TDS Surcharge)) - 0.022.
We have developed this report which displays upto
VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount.
How to show tax break up of TDS in SQL query ?
Thanks,
With regards,
Jeyakanthan.Hi gauraw,
Thank for your reply.
I modified the query , pasted the query
as below in query generator,
Select T0.DocNum,T0.DocDate,T0.CardCode as 'Ledger',T1.TaxbleAmnt As 'Bill value',T1.WTAmnt as 'TDSAmt',(TDSAmt * 0.1) as 'TDS_Surch',
(((TDSAmt0.1) + TDSAmt)0.02) as 'TDSCess',
(((TDSAmt0.1) + TDSAmt)0.01) as 'TDSHCess'
FROM OPCH T0 INNER JOIN PCH5 T1 ON T0.DocEntry = T1.AbsEntry
WHERE (T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]')
on clicking execute its showing error message invalid column
name 'TDSAmt'.
With regards,
Jeyakanthan -
How to use sql query in java ?
i don't know how to use sql query in java code.
who can give me some advice?
thankshttp://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/
-
hi i am face with problem that is i want to show the how much approximate space required for backup or .bak file to get backup using sql query because i want to show the required memory for backup file on my java application
Hi FIROZ
TENNALI
Is this still an issue, or can we close the thread?
* closing a thread by marking the answer/s (there is a link beneath each response) and you can vote for useful responses as well (there is a link to vote on the left of each response)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
How to Use SQL Query having IN Clause With DB Adapter
Hi,
I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
Thanksinvoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter
-
How to numberformat when using sql:query alogn with c:forEach JSTL tags
Is there anyway to format the numeric values returned from the database when using <sql:query> alogn with <c:forEach> tags
Here is my jsp code
<sql:query..../>
<c:forEach var="row" items="${queryResults.rows}">
<tr>
<td><c:out value="${row.COL1}" /></td>
<td><c:out value="${row.COL2}" /></td>
</tr>
</c:forEach>
Col1 values are numeric without any formats Eg: 1000, 10000, 1000000 etc.
how can i format them to 1,000 , 10,1000 , 100,000 etcIt is polite to mention what your answer was. These posts are not just here for you to ask questions, but to be used as a resource for other people to find answers. Saying "I solved it" with no details helps noone.
I presume you discovered the JSTL <fmt:formatNumber> tag? -
How to start or shut down database using sql developer in windows
Dear Sir/Madam,
how we start or shut down database using sql developer in windows
we are using oracle 11g release2, unix, java & oracle oracle weblogic administration
Thanks & Regards
Manish Kumar
Datbase Team
TCS Ltd.HI, Welcome to OTN form,
SHUTDOWN is not a SQL statement but a SQL*Plus command . You cannot use SHUTDOWN in PL/SQL.
Check following link:
http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve042.htm#i2699551
More Information please check OTN discussion: https://forums.oracle.com/thread/2349159
Thank you -
How to backup database using sql query?
Hello,i'm student, i'm researching oracle database,i want to backup database that using sql query (like backup query in SQL SERVER) ,how to do that ??
Thank!No, database backups cannot be done from within the database.
Commands for backups are outside of the database.
See the "2 Day DBA Guide" http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/toc.htm
and the "Backup and Recovery Users's (actually Adminsitrator's) Guide : http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/toc.htm
Hemant K Chitale -
How to get this output using sql query?
Hi,
How to get this output using sql query?
Sno Name Age ADD Result
1 Anil 23 delhi Pass
2 Shruti 25 bangalor Pass
3 Arun 21 delhi fail
4 Sonu 23 pune Pass
5 Roji 26 hydrabad fail
6 Anil 28 delhi pass
Output
Sno Name Age ADD Result
1 Anil 23 delhi pass
28 delhi passHi Vamshi,
Your query is not pretty clear.
write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
Regards,
Kannan -
How to hide repeated details using SQL Query?
How to hide repeated details using SQL Query?
For Ex:
------------------------+
DEPTNO| ENAME | JOB |
------|-------| --------|
10 | JAMES | MANAGER |
10 | BLAKE | CLERK |
10 | FORD | SALESMAN|
20 | SCOTT | MANAGER |
20 | ADAMS | CLERK |
20 | KING | SALESMAN|
------------------------+
How we can display the above details in the following way?
------------------------+
DEPTNO| ENAME | JOB |
------|-------| --------|
10 | JAMES | MANAGER |
| BLAKE | CLERK |
| FORD | SALESMAN|
20 | SCOTT | MANAGER |
| ADAMS | CLERK |
| KING | SALESMAN|
------------------------+
Thanks AdvanceHi,
you can use BREAK ON DEPTNO in SQL*Plus or use LAG.
SQL> ed
Wrote file afiedt.buf
1 select nullif(department_id
2 , lag(department_id) over (partition by department_id order by last_name)
3 ) dept_id
4 , last_name, job_id
5* from employees where department_id in (30,50) and rownum <=10
SQL> /
DEPT_ID LAST_NAME JOB_ID
30 Baida PU_CLERK
Colmenares PU_CLERK
Himuro PU_CLERK
Khoo PU_CLERK
Raphaely PU_MAN
Tobias PU_CLERK
50 Fripp ST_MAN
Kaufling ST_MAN
Vollman ST_MAN
Weiss ST_MAN
10 rows selected. -
How to retrive the blob data from a table using sql query
Hi gurus,
I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
Regards,
vardhani.You can use data templates.
See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
Thanks,
Bipuser -
How to show the VALUE as the Column Header using SQL query?
Hi
I have a requirement to show the picked value as the column header using SQL query.
Example:
======
SELECT EMPNO FROM EMP
WHERE EMPNO=7934;
Result Should be:
7934
7934I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
SQL> set verify on
SQL> def e = 7934
old: SELECT empno "&&e" FROM emp WHERE empno = &&e
new: SELECT empno "7934" FROM emp WHERE empno = 7934
SQL> SELECT empno "7934" FROM emp WHERE empno = 7934
7934
7934
1 row selected. -
How to handle large result set of a SQL query
Hi,
I have a question about how to handle large result set of a SQL query.
My query returns more than a million records. However, the Query Template has a "row count" parameter. If I don't specify it, it by default returns only 100 lines of records in the query result. If I specify it, then it's limited to a specific number.
Is there any way to get around of this row count issue? I don't want any restriction on the number of records returned by a query.
Thanks a lot!No human can manage that much data...in a grid, a chart, or a direct-connected link to the brain.
What you want to implement (much like other customers with similar requirements) is a drill-in and filtering model that helps the user identify and zoom in on data of relevance, not forcing them to scroll through thousands or millions of records.
You can also use a time-based paging model so that you only deal with a time "slice" at one request (e.g. an hour, day, etc...) and provide a scrolling window. This is commonly how large datasets are also dealt with in applications.
I would suggest describing your application in more detail, and we can offer design recommendations and ideas.
- Rick -
How does Index fragmentation and statistics affect the sql query performance
Hi,
How does Index fragmentation and statistics affect the sql query performance
Thanks
Shashikala
ShashikalaHow does Index fragmentation and statistics affect the sql query performance
Very simple answer, outdated statistics will lead optimizer to create bad plans which in turn will require more resources and this will impact performance. If index is fragmented ( mainly clustered index,holds true for Non clustred as well) time spent in finding
the value will be more as query would have to search fragmented index to look for data, additional spaces will increase search time.
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
My TechNet Wiki Articles
Maybe you are looking for
-
Yoga 2 Pro 13.3 Android Poor Battery Life
I am getting between 7 and 8 hours battery life out of my new Yoga Pro 2 13.3" Android tablet just browsing the internet with the screen set to 25% brightness (auto-brightness turned off) and no sound. The power saving screen and GPU settings are tur
-
Account assignment not possible (Asset not assigned to a business area)
HI While posting an asset acquisition through F-90 by entering Business area, doc.type AA,TT-100,PK-70, i am getting the error messege AA483 - "Account assignment not possible (Asset not assigned to a business area)". I have correctly created asset m
-
I try to install itunes in windows 7 professional and it keeps giving me an error hresult dx800736b3
i try to install itunes in windows 7 professional and it keeps giving me an error hresult dx800736b3
-
In BW Loads Checker , there is object selection option, into that we have check box of ( Include Delta Loads) and ( 0 Records Loaded only). when we select one out of two check box it will execute result for that selected check box, now my question i
-
Best IDE on the planet??
Hi All, We have been developing JSP's & Servlets using Borland's JBuilder5 Pro, which is crashing from time to time. So we are looking for alternatives. I had a look on sun's FORTE for Java, but unsure about its performance. Are there any other bulle