Need Query
Hi,
I am working in oracle 9i and linux 2.4. I need a sql query.
select issuer_id, watch_id, last_update_dtm from cats_issuer_opinion ;
Table name = cats_issuer_opinion
in this table issuer_id , watch_id, last_update are three columns. values are below
1 1 20-4-2005
1 1 20-4-2005
1 2 21-4-2005
1 2 21-4-2005
1 1 22-4-2005
2 1 23-4-2005
2 2 24-4-2005
this is the table details..my question is i need a sql query that result will be
when the issuer_id = 1 at that time watch_id is changing from 1 to 2 and 2 to 1 . i need the result as how many times this is to be changed along with the date.and also when the issuer_id=2 at that time how many times the watch_id is changed from 1 to 2 and 2 to 1 along with the date.
this is for issuer_id=100
please give the detail sql query....
Cheers..
SQL> create table cats_issuer_opinion
2 as
3 select 1 issuer_id, 1 watch_id, to_date('20042005 060000','ddmmyyyy hh24miss') last_update from dual union all
4 select 1, 1, to_date('20042005 160000','ddmmyyyy hh24miss') from dual union all
5 select 1, 2, to_date('21042005 060000','ddmmyyyy hh24miss') from dual union all
6 select 1, 2, to_date('21042005 160000','ddmmyyyy hh24miss') from dual union all
7 select 1, 1, to_date('22042005 060000','ddmmyyyy hh24miss') from dual union all
8 select 2, 1, to_date('23042005 060000','ddmmyyyy hh24miss') from dual union all
9 select 2, 2, to_date('24042005 060000','ddmmyyyy hh24miss') from dual
10 /
Tabel is aangemaakt.
SQL> select issuer_id
2 , prev_watch_id watch_id_from
3 , watch_id watch_id_to
4 , last_update
5 from ( select t.*
6 , lag(watch_id) over (partition by issuer_id order by last_update) prev_watch_id
7 from cats_issuer_opinion t
8 )
9 where watch_id + prev_watch_id = 3
10 /
ISSUER_ID WATCH_ID_FROM WATCH_ID_TO LAST_UPDATE
1 1 2 21-04-2005 06:00:00
1 2 1 22-04-2005 06:00:00
2 1 2 24-04-2005 06:00:00
3 rijen zijn geselecteerd.Regards,
Rob.
Similar Messages
-
Need query to find out whether exactly 2 columns are used in any index ?
Suppose i have two columns ID and Status (or any number of columns ) belongs to table customer...
Now I want to create below index
Ex. create index test1 on customer (ID , Status )
But before creating this index i want to check that whether there is already index on these 2 columns ? May be by other name ?
Need query for this.
Plz help.Hi Shubhangi,
Your requirement is very difficult to fulfill , i have made an attempt to replicate your reqrmnt & write a query wherein you need to compromise on few things , let us see if it works for you
Supply table_name/owner & Number of column on which you want to find indexes
e.g.
select distinct INDEX_NAME,column_name
from dba_ind_columns
where index_name in (select distinct index_name
from dba_ind_columns
where table_name='&table_name'
and table_owner='&owner'
having count(column_name)=&column_count group by index_name);
Enter value for table_name: ADDRESS
Enter value for owner: ASAP
Enter value for column_count: 2
INDEX_NAME COLUMN_NAME
FKIDX_AD__SF_ST_FO SF_STRUC_FORMAT_NM
FKIDX_AD__SF_ST_FO SF_TYPE_NM
SQL> /
Enter value for table_name: ADDRESS
Enter value for owner: ASAP
Enter value for column_count: 3
INDEX_NAME COLUMN_NAME
FKIDX_AD__SF_ST_FO_1 POSTAL_CD
FKIDX_AD__SF_ST_FO_1 SF_STRUC_FORMAT_NM
FKIDX_AD__SF_ST_FO_1 SF_TYPE_NM
Thanks,
Ajay More
http://moreajays.blogspot.com -
hi
i need query to find out for one perticular row from parent table ,,which references how many rows in how many child tables , and child to child tables. in herirachy fashion.
if anybody know please help meI guess it would be difficult to come up with a generic script to get answer that can help in all situations...you have to see the table definitions in your schema and try...like in case of emp and dept table,
select * from dept where deptno in
(select deptno,count(*) from emp group by deptno having count(*)>1)
(this gives rows from dept table where , for corresponding deptno there are more than one rows in emp table).
Thanks
Nirav -
Need Query - join in same table
I need query for following criteria,
Table : test
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
Consider the above table,
1) I will give input order as a,b: It should return No 1,2
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
2) I will give input order as f,g,h: It should return No 3
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
Please give me the query which will give above result.
ThanksI am not sure I understand you, but it may be this
with test as (
select 1 N, 'a' Ord from dual union all
select 1,'b' from dual union all
select 1,'c' from dual union all
select 2,'a' from dual union all
select 2,'b' from dual union all
select 2,'d' from dual union all
select 3,'e' from dual union all
select 3,'f' from dual union all
select 3,'g' from dual union all
select 3,'h' from dual union all
select 1,'f' from dual union all
select 2,'f' from dual )
select N from test tp where Ord = 'a'
intersect
select N from test tp where Ord = 'b';
with test as (
select 1 N, 'a' Ord from dual union all
select 1,'b' from dual union all
select 1,'c' from dual union all
select 2,'a' from dual union all
select 2,'b' from dual union all
select 2,'d' from dual union all
select 3,'e' from dual union all
select 3,'f' from dual union all
select 3,'g' from dual union all
select 3,'h' from dual union all
select 1,'f' from dual union all
select 2,'f' from dual )
select N from test tp where Ord = 'f'
intersect
select N from test tp where Ord = 'g'
intersect
select N from test tp where Ord = 'h'; -
Hi Folks,
I need query for displaying following:
Adjusted A/R Balance:-
Sum of all open Receivables transactions for the Bill To address for a :Particular_Customer. Total of all open items (Invoice, Credit Memos, CLAIMS, ON ACCTS, UNAPPLIED, DEBIT MEMOS) PLUS any orders that have been approved but not yet invoiced.
================================================================================
Credit Tolerance:-
Percentage of Credit Limit that is the allowed tolerance for exceeding the credit limit. Determined by the following calculation: (Exposure Credit Limit ((Credit Tolerance + 100)* Credit Limit / 100) – Credit Limit)/Credit Limit.
would be very greatful if someone can help on same.
Thanks in advance.
Regards,
gvk.another example would be:
SQL> with emp1 as
2 (select 10 emp_id, 'AAAA' emp_name from dual
3 union all
4 select 22 emp_id, 'BBBB' emp_name from dual
5 union all
6 select 15 emp_id, 'BBBB' emp_name from dual
7 union all
8 select 17 emp_id, 'cccc' emp_name from dual
9 union all
10 select 4 emp_id, 'DDDD' emp_name from dual
11 union all
12 select 5 emp_id, 'EEEE' emp_name from dual
13 union all
14 select 53 emp_id, 'EEEE' emp_name from dual)
15 select emp_id id, emp_name name from emp1;
ID NAME
10 AAAA
22 BBBB
15 BBBB
17 cccc
4 DDDD
5 EEEE
53 EEEE
7 rows selected.
SQL> with emp1 as
2 (select 10 emp_id, 'AAAA' emp_name from dual
3 union all
4 select 22 emp_id, 'BBBB' emp_name from dual
5 union all
6 select 15 emp_id, 'BBBB' emp_name from dual
7 union all
8 select 17 emp_id, 'cccc' emp_name from dual
9 union all
10 select 4 emp_id, 'DDDD' emp_name from dual
11 union all
12 select 5 emp_id, 'EEEE' emp_name from dual
13 union all
14 select 53 emp_id, 'EEEE' emp_name from dual)
15 select row_number() over (order by emp_name, emp_id) rn,
16 emp_id id,
17 emp_name name
18 from emp1;
RN ID NAME
1 10 AAAA
2 15 BBBB
3 22 BBBB
4 4 DDDD
5 5 EEEE
6 53 EEEE
7 17 cccc
7 rows selected.
SQL> -
Need Query for empty partitions
I am having nearly 700 partitions for a table.Now i want to find out only the empty partitions.I need query for that.
Thankx..Not the most elegant solution, but it works:
declare
rc number;
str varchar2(200);
begin
for i in (select table_owner, table_name, partition_name from dba_tab_partitions) loop
str := 'select count(*) from ' || i.table_owner || '.' || i.table_name || ' partition (' || i.partition_name || ')';
execute immediate str into rc;
if rc = 0 then
dbms_output.put_line(i.table_owner || '.' || i.table_name);
end if;
end loop;
end; -
Need query help regarding employee retirement age.
Need query to find employee retirement age 2years in advance.
You can use per_all_people_f table.
something like this :-
SELECT PAPF.employee_number,
PAPF.date_of_birth,
(MONTHS_BETWEEN(SYSDATE,PAPF.date_of_birth) / 12)+2 RETIREMENT_AGE_FIGURE
FROM per_all_people_f PAPF
WHERE TRUNC (SYSDATE) BETWEEN PAPF.effective_Start_date AND PAPF.effective_end_date
AND (MONTHS_BETWEEN(SYSDATE,date_of_birth) / 12)+2 >=65 /* ASSUMING 65 IS RETIREMENT AGE HERE*/
In case if you only want to pick Employee data then use below sample query and modify according to your requirement :-
SELECT PAPF.employee_number,
PAPF.date_of_birth,
((MONTHS_BETWEEN(SYSDATE,PAPF.date_of_birth) / 12)+2) RETIREMENT_AGE_FIGURE,
PPT.system_person_type,
PPT.user_person_type
FROM per_all_people_f PAPF,
per_person_types PPT,
per_person_type_usages_f PPTUF
WHERE TRUNC (SYSDATE) BETWEEN PAPF.effective_Start_date AND PAPF.effective_end_date
AND ((MONTHS_BETWEEN(SYSDATE,date_of_birth) / 12)+2) >=65
AND PPTUF.person_id = PAPF.person_id
AND PPT.person_type_id = PPTUF.person_type_id
AND PPT.system_person_type = 'EMP'
AND TRUNC (SYSDATE) BETWEEN PPTUF.effective_Start_date AND PPTUF.effective_end_date
Edited by: VISHAL DANGI on Jul 8, 2012 10:30 PM -
I need query to split the string
I need query to split the input string into comma seperated triplets values.
Input String: Database
Output : Dat, ata,tab,aba,bas,aseSQL> with t
2 as
3 (
4 select 'Database' str
5 from dual
6 )
7 select substr(str, level, 3) str
8 from t
9 where length(substr(str, level, 3)) = 3
10 connect by level <= length(str);
STR
Dat
ata
tab
aba
bas
ase
6 rows selected.
And if you want it as a single string then..
SQL> with t
2 as
3 (
4 select 'Database' str
5 from dual
6 )
7 select ltrim(sys_connect_by_path(str, ','), ',') str
8 from (
9 select row_number() over(order by level) rno
10 , substr(str, level, 3) str
11 from t
12 where length(substr(str, level, 3)) = 3
13 connect by level <= length(str)
14 )
15 where connect_by_isleaf = 1
16 start with rno = 1
17 connect by rno = prior rno + 1;
STR
Dat,ata,tab,aba,bas,ase -
Urgent Need: Query is taking time
Hi,
I have a query which is taking lots of time.Please help me in this regard...
select subscripti0_.RENTAL_ID as RENTAL1_101_0_, movieprodu1_.product_id as product1_45_1_, moviepacka2_.PACKAGE_ID as PACKAGE1_47_2_, movietitle3_.TITLE_ID as TITLE1_48_3_, subscripti0_.LOGICAL_QUEUE_POSITION as LOGICAL2_101_0_, subscripti0_.STATUS as STATUS101_0_, subscripti0_.RENT_CODE as RENT4_101_0_, subscripti0_.IS_VISIBLE_FLAG as IS5_101_0_, subscripti0_.SHIP_DATE as SHIP6_101_0_, subscripti0_.DATE_CHECK_IN as DATE7_101_0_, subscripti0_.SET_NBR as SET8_101_0_, subscripti0_.ALLOCATION_DATE as ALLOCATION9_101_0_, subscripti0_.USPS_SHIP_DATE as USPS10_101_0_, subscripti0_.CENTRAL_CHECKIN_DATE as CENTRAL11_101_0_, subscripti0_.ESTIMATED_ARRIVAL_DATE as ESTIMATED12_101_0_, subscripti0_.CREATED_BY as CREATED13_101_0_, subscripti0_.CREATED_DATE as CREATED14_101_0_, subscripti0_.UPDATED_BY as UPDATED15_101_0_, subscripti0_.UPDATED_DATE as UPDATED16_101_0_, subscripti0_.SUBSCRIPTION_ID as SUBSCRI17_101_0_, subscripti0_.MOVIE_ID as MOVIE18_101_0_, movieprodu1_.ONLINE_RELEASE_DATE as ONLINE2_45_1_, movieprodu1_.PRODUCT_TITLE as PRODUCT3_45_1_, movieprodu1_.PACKAGE_ID as PACKAGE4_45_1_, movieprodu1_1_.AVAILABILITY_BAND as AVAILABI2_46_1_, movieprodu1_1_.TOTAL_RENTABLE_INVENTORY as TOTAL3_46_1_, NVL(movieprodu1_.ONLINE_FLAG, 0) as formula0_1_, NVL(movieprodu1_.PRIMARY_PRODUCT, 0) as formula1_1_, moviepacka2_.TITLE as TITLE47_2_, moviepacka2_.dvd_release_date as dvd3_47_2_, moviepacka2_.FORMAT as FORMAT47_2_, moviepacka2_.PACKAGE_MPAA as PACKAGE5_47_ 2_, moviepacka2_.T_ARTICLE as T6_47_2_, moviepacka2_.TITLE_ID as TITLE7_47_2_, movietitle3_.TITLE as TITLE48_3_, movietitle3_.THEATRICAL_RELEASE as THEATRICAL3_48_3_, movietitle3_.TITLE_MPAA as TITLE4_48_3_, movietitle3_.LEGACY_ID as LEGACY5_48_3_, movietitle3_.AVERAGE_USER_RATING as AVERAGE6_48_3_, movietitle3_.RUNNING_TIME as RUNNING7_48_3_, movietitle3_.PRIMARY_PACKAGE_ID as PRIMARY8_48_3_, movietitle3_1_.BUY_NEW as BUY2_49_3_, movietitle3_1_.BUY_USED as BUY3_49_3_, movietitle3_1_.RENT_DOWNLOAD as RENT4_49_3_, movietitle3_1_.BUY_DOWNLOAD as BUY5_49_3_, NVL(movietitle3_.HAS_RENTABLE_PRODUCTS, 0) as formula3_3_ from SUBSCRIPTION_RENTAL subscripti0_ inner join ACTIVE_MOVIE_PRODUCT movieprodu1_ on subscripti0_.MOVIE_ID=movieprodu1_.product_id left outer join PRODUCT_AVAILABILITY movieprodu1_1_ on movieprodu1_.product_id=movieprodu1_1_.MOVIE_ID inner join ACTIVE_MOVIE_PACKAGE moviepacka2_ on movieprodu1_.PACKAGE_ID=moviepacka2_.PACKAGE_ID inner join ACTIVE_MOVIE_TITLE movietitle3_ on moviepacka2_.TITLE_ID=movietitle3_.TITLE_ID left outer join MOVIE_TITLE_ATTRIBUTES movietitle3_1_ on movietitle3_.TITLE_ID=movietitle3_1_.TITLE_ID where subscripti0_.SUBSCRIPTION_ID=:1 and subscripti0_.DATE_CHECK_IN>:2 and (subscripti0_.DATE_CHECK_IN is not null) order by subscripti0_.DATE_CHECK_IN DESC
Explain Plan for this query:
OPERATION OBJECT_NAME OPTIMIZER COST BYTES CARDINALITY CPU_COST IO_COST
SELECT STATEMENT ALL_ROWS 148 1570 5 10090819 147
SORT 148 1570 5 10090819 147
NESTED LOOPS 147 1570 5 1237900 147
NESTED LOOPS 142 1530 5 1191042 142
NESTED LOOPS 141 1470 5 1174111 141
NESTED LOOPS 129 1398 6 1073114 129
NESTED LOOPS 117 1062 6 968996 117
PARTITION HASH 111 732 6 911328 111
TABLE ACCESS SUBSCRIPTION_RENTAL ANALYZED 111 732 6 911328 111
INDEX INDX_SUB_RENTAL_SUB ANALYZED 3 10 43164 3
TABLE ACCESS MOVIE_PRODUCT ANALYZED 1 55 1 9611 1
INDEX PK_MOVIE_PRODUCT ANALYZED 0 1 1900 0
TABLE ACCESS MOVIE_PACKAGE ANALYZED 2 56 1 17353 2
INDEX PK_MOVIE_PACKAGE ANALYZED 1 1 9021 1
TABLE ACCESS MOVIE_TITLE ANALYZED 2 61 1 16833 2
INDEX PK_MOVIE_TITLE ANALYZED 1 1 9021 1
TABLE ACCESS MOVIE_TITLE_ATTRIBUTES ANALYZED 1 12 1 9331 1
INDEX PK_MOVIE_TITLE_ATTRIBUTES ANALYZED 0 1 1900 0
TABLE ACCESS PRODUCT_AVAILABILITY ANALYZED 1 8 1 9371 1
INDEX PRODUCT_AVAILABILITY_PK ANALYZED 0 1 1900 0
I need the help very urgently. Kindly give me the solution immediately.
Edited by: msora on Feb 10, 2009 3:19 AMmsora wrote:
Thanks Ozy,
The query is using joins instead of subquery. The statistics are latest. the query is using indexes too.the optimzer_mode is all_rows.
Now, you tell me what hint i should use to optimize this query?
Thanks and Regards,
MSORAHmm, urgent, immediately, its not Support MSORA. Be patient while asking for help or if its really urgent, open an SR with support.
Your query is not able to be read. Format it using the { code }( without spaces) and post it. Also there is no such thing that you can just put any hint and query will be tuned. Trace your query with 10046 trace( search this forum for that) and paste its output here.
Aman.... -
Hi,
I have employee table, i need to show the details of employees who are working under a manager till this it ok,but i have one more conditon is that, if the manager has any sub mangers, i need to show the employees who are working under sub mangare.
empno ename mgrid are the main fileds in my table
Please help me in this by providing a query or creating a tree
thanks
Regards,
RajeshHi,
Do you mean something like this -
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-NOV-81 10
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7566 JONES MANAGER 7839 02-APR-81 2975 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7934 MILLER CLERK 7782 23-JAN-82 1300 10
SQL> select
2 lpad('*', level * 2) || ename as ename
3 from
4 emp
5 start with mgr is null
6 connect by prior empno = mgr;
ENAME
*KING
*BLAKE
*ALLEN
*WARD
*MARTIN
*TURNER
*JAMES
*CLARK
*MILLER
*JONES
*SCOTT
*ADAMS
*FORD
*SMITH
14 rows selected. -
Need query to find out the sum till a period
Hi,
I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
Thanksnot familiar with report but could you do something like this
with t as
select 1 grp, 10 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11 union all
select 2 grp, 5 * level the_cost, add_months (sysdate, level) effective_dt from dual connect by level < 11
input as
( select null grp, null the_cost, null running_total, v_eff_dt effective_dt from dual)
select * from(
select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
input.effective_dt inp_eff_dt
from t, input
where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in -
Need Query for Item Relationship of Oracle Apps
Hello Team,
I need the Query to select the Item Relationship.
In Oracle Apps we have different tyes of Structure
ItemA -> ItemB
ItemB -> ItemC
ItemC -> ItemD
ItemG -> ItemH
ItemK -> ItemL
ItemW -> ItemQ
and this also is possible (meand many to one relationship)
ItemA -> ItemB
ItemB -> ItemC
ItemC -> ItemD
ItemT -> ItemD
and in the Select Query i want the below result
ItemA -> ItemB 1
ItemB -> ItemC 2
ItemC -> ItemD 3
ItemG -> ItemH 1
ItemK -> ItemL 2
ItemW -> ItemQ 1
and this also is possible (means many to one relationship)
ItemA -> ItemB 1
ItemB -> ItemC 2
ItemC -> ItemD 3
ItemT -> ItemD 1
means i want the Hierarchy number also
Please help me to in order to get the relationship by sql query.
Kind Regards,thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today. i'll do that now though.
what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system. there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc? -
Guys,
I've been trying to solve the shortest route problem and got stuck in calculating the cumulative distance in a hierarchial query. I've got some idea to deal with it like
sum(distance) over (order by level rows level preceding)But in order for this to happen I may be needing duplicate records. Anyway, let me get straight to what I need.
I have table data like this.
col1 col2 rown
1 10 1
2 20 2
3 30 3
4 40 4
4 70 5
5 80 6
3 90 7
5 95 8I want the result to be like this.
col1 col2
1 10
2 20
3 30
4 40
1 10
2 20
3 30
4 70
5 80
1 10
2 20
3 90
1 10
2 20
3 30
4 70
5 95Please observe that when filling with duplicates, if there are 2 or more occurances of the same, it should be the latest(maximum rown in all). For eg: To fill for 5---95, there are two 3s (3---30 and 3---90) and two 4s(4---40 and 4---70). The latest need to be taken meaning 3---90 and 4---70 are to be taken. I hope I made it clear. Please let me know if you need any further information.
Cheers
Sarma.Thank you Etbin.
It was line # 16 that was missing. Now it looks okay.
SQL> select finaal.col1, finaal.col2
2 from (select col1, col2, rown,
3 row_number() over (partition by col1, rown
4 order by col2 desc) rn
5 from ( select b.col1 col1,
6 b.col2 col2,
7 a.rn rown
8 from sample b, (select col1, col2, rown, rn
9 from (select col1, col2, rown, rownum rn,
10 lag(col1) over (order by rown) prev
11 from sample
12 )
13 where col1 - prev <> 1
14 ) a
15 where b.col1 < a.col1
16 and b.rown <= a.rown
17 union all
18 select col1,
19 col2,
20 rown
21 from sample
22 )
23 ) finaal
24 where finaal.rn = 1
25 order by finaal.rown, finaal.col1
26 /
COL1 COL2
1 10
2 20
3 30
4 40
1 10
2 20
3 30
4 70
5 80
1 10
2 20
3 90
1 10
2 20
3 90
4 70
5 95
1 15
1 15
2 20
3 90
4 80
1 15
2 20
3 90
4 80
5 95
6 99
1 15
2 20
3 33
1 15
2 20
3 90
4 80
5 97
36 rows selected.
SQL>Cheers
Sarma. -
Need Query to that generate count of rows of all tables
Hi
i need a query which gives the result of no.of rows in talbe and coresponding table name.
And then i need to compare the same with other DB schema
Thanks in advanceHi User,
We can also get the count of rows for all the tables associated with a User, we can create a custom function which
uses the table name to return results.
CREATE OR REPLACE FUNCTION TAB_ROWS_CNT (TAB_NAME IN VARCHAR2)
RETURN NUMBER
AS
TAB_CNT NUMBER :=0;
BEGIN
EXECUTE IMMEDIATE 'select count(*) from ' || TAB_NAME
INTO TAB_CNT;
RETURN TAB_CNT;
END;And query,
SELECT TABLE_NAME, TAB_ROWS_CNT (TABLE_NAME) ROW_CNT
FROM USER_TABLES;Which gets us the count of Individual Tables for a user.
This is an just that we can do in this way also. But, use which is optimal.
Thanks,
Shankar -
Need query or proc for this req
Hi,
I need a proc for the below requirement.
I will pass 3 numbers to the procedure like 1,4,5 which should result in all possible combinations of 3.
The return value from the procedure is all combinations of 1,4,5 like as below:
1,4,5
1,5,4
4,1,5
4,5,1
5,1,4
5,4,1 Edited by: Sun Vth Oracle on Jul 29, 2012 10:14 PMVenkadesh,
I totally agree with your solution.
Perhaps just reformatting your query.
WITH t
AS (SELECT 1 col FROM DUAL
UNION ALL
SELECT 4 FROM DUAL
UNION ALL
SELECT 5 FROM DUAL),
tmp
AS (SELECT DISTINCT SYS_CONNECT_BY_PATH (col, ',') str
FROM t
CONNECT BY LEVEL <= 3)
SELECT SUBSTR (str, 2)
FROM tmp
WHERE LENGTH (REPLACE (str, ',')) = 3;Cheers,
Manik.
Maybe you are looking for
-
Replacement Question: Ipod 20G 4th Gen Vs. Ipod 30G 5th Gen
The 20G non-color display Ipod that I owned for 18 months died mysteriously last Sunday. I lifted it out of the charge dock after it fully charged and the click wheel had become completely unresponsive. The video display was fully functional.... but
-
I have program to store Arabic string and save it in text file i use Eclpise there i did change the encoding to UTF-8 so i can read the string and print it fine but when i save it as a text file in c drive i get this ��������;����������������������;�
-
HP P7-1414 ram upgrade question
I just have a question just to make sure if this memory works for my computer Crucial 4GB Kit (2GBx2) DDR3-1600 MT/s (PC3-12800) Non-ECC UDIMM 240-Pin Desktop Memory CT2KIT25664BA160B / CT2CP25664BA160B 2 sockets are available
-
Ok I obviously have some time on my hands and I'm getting ready to start using Motion more often the AE for projects so here is another question(s). In short how do you make a still frame in the middle of a video clip that will hold through the remai
-
TS1363 ipod classic not working with win xp not sure how to sync it?
ipod classic not working with win xp not sure how to sync it?