Need query to find rows
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 me
I 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
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 -
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 to find repeating values, please help
I need help with SQL or whatever you guys think is the best way to do this, maybe PL/SQL.
Basically it like this, in the database 10G, there are two field for address:
ADDESS_DELVRY - street address for example would be stored here
ADDESS_DELVRY2 - apartment building, suite number or PBM would be stored here
but sometimes I see the Apartment B-123 in both fields, so I need to find those duplicates, if there is a way.
So for example:
ADDESS_DELVRY - 123 Elm Street Apartment 2B
ADDESS_DELVRY2 - Apartment 2B
This is a problem, because then the Apartment gets printed twice on the mail piece. I think there is a small percentage that have this problem and am trying to find out the best way to ID them, maybe use REG_EXP ??
Not sure, please help, thanks!Soundex works how it's designed to work, which unfortunately is a very poor approximation at words sounding the same.
Using the UTL_MATCH package is a far better way to check for similarity between strings.
Ok. Given the OPs challenge here; a simple, or messy (we don't know), data cleaning task, I think soundex was worth mentioning.
Also, the reply that "soundex don't [doesn't] work" , given a working example , I think we can safely conclude
that UTL_MATCH is way above his league.
I don't understand how the OP has better use of
SELECT UTL_MATCH.EDIT_DISTANCE('Second Avenue 12 second floor', 'second fl.') dist FROM DUAL;
DIST
20
1 row selected.than
SELECT *
FROM dual
WHERE SOUNDEX ('Second Avenue 12 second floor') = SOUNDEX ('second fl.')
X
1 row selected.given the task at hand, but all right I'm not going to argue either. -
Need Query to find Pending Quantity for Receipts
Hi all,
Can any one please help me in finding the pending quantity for a particular Receipt.
ex. If a receipt has
transaction_type Quantity
Receive 15
Accept 5
Deliver 5
then my accepted quantity should be (Receive-Deliver) = 10
I have written a query
SELECT RSH.RECEIPT_NUM RECEIPT_NUM, RSH.CREATION_DATE CREATION_DATE, RT.TRANSACTION_TYPE TRANSACTION_TYPE, NVL(RT.QUANTITY, 0) QUANTITY,rt.destination_type_code destination_type_code,
RT.UNIT_OF_MEASURE UNIT_OF_MEASURE, RSL.ITEM_DESCRIPTION ITEM_DESCRIPTION, NVL(RT.PO_UNIT_PRICE, 0) PO_UNIT_PRICE,
RT.CURRENCY_CODE CURRENCY_CODE, NVL(RT.CURRENCY_CONVERSION_RATE,0) RATE, RSL.SHIPMENT_LINE_ID SHIPMENT_LINE_ID,
NVL(RT.QUANTITY * RT.PO_UNIT_PRICE * RT.CURRENCY_CONVERSION_RATE ,0) VALUE
FROM RCV_TRANSACTIONS RT, RCV_SHIPMENT_HEADERS RSH, RCV_SHIPMENT_LINES RSL, PO_VENDORS POV, PO_VENDOR_SITES POVS,
ORG_ORGANIZATION_DEFINITIONS ORG, HR_LOCATIONS_ALL_TL HRL, PO_LOOKUP_CODES PLC,
RCV_SUPPLY RS
WHERE RSH.SHIPMENT_HEADER_ID = RT.SHIPMENT_HEADER_ID
AND RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
AND RSH.RECEIPT_NUM IS NOT NULL
AND POV.VENDOR_ID (+) = RSH.VENDOR_ID
AND POVS.VENDOR_SITE_ID (+) = RSH.VENDOR_SITE_ID
AND HRL.LOCATION_ID (+) = RSH.SHIP_TO_LOCATION_ID AND HRL.LANGUAGE(+) = USERENV('LANG')
AND ORG.ORGANIZATION_ID (+) = RSH.ORGANIZATION_ID AND RSH.RECEIPT_SOURCE_CODE = PLC.LOOKUP_CODE
AND PLC.LOOKUP_TYPE = 'SHIPMENT SOURCE TYPE'
AND RS.RCV_TRANSACTION_ID = RT.TRANSACTION_ID
AND RT.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
AND RT.TRANSACTION_TYPE IN ('RECEIVE','TRANSFER')
ORDER BY 1
I want want the pending quantity...
Please helpYou can get the quantities in po line locations, then you can find the balance quantity to be received.
you can get the following from po line locations.
quantity
quantity_received
quantiy_accepted
quantity_rejected
quantity_billed
quantity_cancelled
--Prasanth -
Need query to find out standby database sync information
Hi All,
Please provide me query which give me information about how many standby database configured .I need to generate report hourly sync information of database in our project. I have more than 120 production db and some db having more than one standby database.some of then at local satndby (some of database (prod) in datacenter and some of database in DR datacenter)
Does it it possible to configure in 12c oem?.If it is possible guide me.How can I create report for all databases sync status within one report?
Thanks
GaneshHello;
I like this one:
Monitor Data Guard Transport
Best Regards
mseberg -
Need query to find out object Accessibility
Hi Gurus,
I am in need of a query that can show object accessibiliy .i.e
given table can be accessed by which all oracle users.
it should take into account grants given by roles.
Please help.
Regradsuser5228856 wrote:
the solution you give me l give me a all out report ,
what i need is
select <<>>
from <<>>
where object_name = owner.object_name
result set should return what all db user has select priv on the given object.site below contains desired code
http://www.petefinnigan.com/tools.htm -
Need query to find the minimum size of a datafile
Hi All,
I need to reduce the size of a datafile. Before that i need to find out how far i can reduce the size of the datafile. Please help
DB version:11.2.0.3
OS:AIX 6.1Below SQL will ask you blocksize (I guess it is default i.e. 8192) :
select 'alter database datafile '''||file_name||''' resize ' ||
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) || 'm;' cmd
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents
group by file_id ) b
where a.file_id = b.file_id(+)
and ceil( blocks*&&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0
It will tell you upto how much extend you can shrink your datafile.
Regards
Girish Sharma -
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 -
Need helping in writing query for finding percentage of duration
Can any one please help in writing query for this.
The table is like this :-
ID Region Month Duration
I1 R1 Jan 80
I2 R2 Jan 70
I3 R1 Jan 70
I4 R3 Jan 40
I5 R1 Feb 80
I6 R2 Feb 30
I7 R3 Mar 100
I want to write a query to find
% of duration for each and every region against each and every month.
Please help in solving this query. I am in urgent need of this.
Thanks in advance.I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
Nicolas. -
Need a query to find Grops mapped on Folders
Hi ,
I need a query builder query to find out the list of folder and mapped groups to those folder.
Would you please let me know if that is possible I triead but no luck .
Regards,
NeoHi,
This query sound goods but I get error
Select SI_NAME, SI_KIND From CI_APPOBJECTS, CI_INFOOBJECTS
Where PARENTS("SI_NAME='Myfolder'",'CHILDREN(''SI_NAME=''UserGroup''')")
Please let me know if I am giong in right direction becuse I never used Parents and child concept bit confused.
All I need is when I put in my folder name it has to show me all the groups mapped to it.
If this query gives the result , it will be the great logic I would say
Thanks a ot.
Neo A -
Write the sql query to find largest value in row wise without using great
write the sql query to find largest value in row wise without using
greatest fuction?Another not so good way, considering you want greatest of 4 fields from a single record:
SQL> ed
Wrote file afiedt.buf
1 with t as (Select 100 col1,200 col2,300 col3,400 col4 from dual
2 union select 500,600,700,800 from dual
3 union select 900,1000,1100,1200 from dual
4 union select 1300,1400,1500,1600 from dual
5 union select 1700,1800,1900,2000 from dual
6 union select 2100,2200,2300,2400 from dual
7 union select 2800,2700,2600,2500 from dual
8 union select 2900,3000,3100,3200 from dual)
9 SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) Max_value
10 FROM
11 (SELECT (CASE WHEN col1_col2 > col2_col3 THEN col1_col2 ELSE col2_col3 END) col1,
12 (CASE WHEN col2_col3 > col3_col4 THEN col2_col3 ELSE col3_col4 END) col2,
13 (CASE WHEN col3_col4 > col4_col1 THEN col3_col4 ELSE col4_col1 END) col3
14 FROM
15 (SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) col1_col2,
16 (CASE WHEN col2 > col3 THEN col2 ELSE col3 END) col2_col3,
17 (CASE WHEN col3 > col4 THEN col3 ELSE col4 END) col3_col4,
18 (CASE WHEN col4 > col1 THEN col4 ELSE col1 END) col4_col1
19* FROM t))
SQL> /
MAX_VALUE
400
800
1200
1600
2000
2400
2800
3200
8 rows selected.
SQL> Edited by: AP on Sep 21, 2010 6:29 AM -
Hi,
can any one help me the query to find the duplicate data from a column.maybe this example might be of some help.
SQL> select * from employees;
YEAR EM NAME PO
2001 04 Sarah 02
2001 05 Susie 06
2001 02 Scott 91
2001 02 Scott 01
2001 02 Scott 07
2001 03 Tom 81
2001 03 Tom 84
2001 03 Tom 87
8 rows selected.
SQL> -- based on the output above we know that there is duplicates on scott and tom
SQL> -- now we need to identified how many are duplicates by grouping into year, empcode, and name
SQL> select year, empcode, name, position,
2 row_number() over (partition by year, empcode, name
3 order by year, empcode, name, position) as rn,
4 count(*) over (partition by year, empcode, name) as cnt
5 from employees;
YEAR EM NAME PO RN CNT
2001 02 Scott 01 1 3
2001 02 Scott 07 2 3
2001 02 Scott 91 3 3
2001 03 Tom 81 1 3
2001 03 Tom 84 2 3
2001 03 Tom 87 3 3
2001 04 Sarah 02 1 1
2001 05 Susie 06 1 1
8 rows selected.
SQL> -- we have identified the duplicates on the above outputs by the counts
SQL> -- now we want to query only rows that has duplicates
SQL> select emp.year, emp.empcode, emp.name, emp.position, emp.cnt
2 from (select year, empcode, name, position,
3 row_number() over (partition by year, empcode, name
4 order by year, empcode, name, position) as rn,
5 count(*) over (partition by year, empcode, name) as cnt
6 from employees) emp
7 where rn = 1
8 and cnt > 1;
YEAR EM NAME PO CNT
2001 02 Scott 01 3
2001 03 Tom 81 3
SQL> -
Need help in finding patterns and there counts
Hi All,
I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
Consider sample data - one row's column from a table:
"S-S-S-P-S-B-S-S-C-S-P"
My requirement is:
I should get all the patterns that are followed by 'S'.
Example: for the above given data the patterns and counts are
SS - count is 3
SP - count is 2
SB - count is 1
SS - count is 1
There is one more condition for the above requirement:
If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
Consider sample data for the above case:
"S-S-A-S-S-A-A-C-S-P-S-A"
for the above given data the patterns and counts are
SS - count is 2
SP - count is 1
SAS - count is 1
SAAC - count is 1
The data column is stored as VARCHAR2 type.
I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
Thanks in advance,
Girish GHi, Girish,
Girish G wrote:
Hi All,
I need help in finding patterns as well as number of occurrences of those patterns in a table's column's data.
Consider sample data - one row's column from a table:
"S-S-S-P-S-B-S-S-C-S-P"
My requirement is:
I should get all the patterns that are followed by 'S'.Do you mean "I should get all patterns that *start with* 'S'"?
Example: for the above given data the patterns and counts are
SS - count is 3
SP - count is 2
SB - count is 1
SS - count is 1Why are there two rows of output for 'SS'? What does the second one, with count=1, mean?
There is one more condition for the above requirement:
If 'S' is followed by 'A', then 'SA' should not be considered as a pattern. The pattern should stretch until a non 'A' character is found.
Consider sample data for the above case:
"S-S-A-S-S-A-A-C-S-P-S-A"
for the above given data the patterns and counts are
SS - count is 2
SP - count is 1
SAS - count is 1
SAAC - count is 1
The data column is stored as VARCHAR2 type.
I have Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit ProductionThanks; the version information is very helpful.
Thanks in advance,
Girish GWhenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
For example, your sample data might be:
CREATE TABLE table_x
( x_id NUMBER PRIMARY KEY
, txt VARCHAR2 (30)
INSERT INTO table_x (x_id, txt) VALUES (1, 'S-S-S-P-S-B-S-S-C-S-P');
INSERT INTO table_x (x_id, txt) VALUES (2, 'S-S-A-S-S-A-A-C-S-P-S-A');and the results you want from that data might be:
X_ID TXT PATTERN CNT
1 S-S-S-P-S-B-S-S-C-S-P SB 1
1 S-S-S-P-S-B-S-S-C-S-P SC 1
1 S-S-S-P-S-B-S-S-C-S-P SP 2
1 S-S-S-P-S-B-S-S-C-S-P SS 3
2 S-S-A-S-S-A-A-C-S-P-S-A SAAC 1
2 S-S-A-S-S-A-A-C-S-P-S-A SAS 1
2 S-S-A-S-S-A-A-C-S-P-S-A SP 1
2 S-S-A-S-S-A-A-C-S-P-S-A SS 2(This corresponds to what you posted, except that there is only one output row for 'SS' when x_id=1.)
One way to get those results in Oracle 11 is:
WITH got_s_cnt AS
SELECT x_id, txt
, REGEXP_COUNT (txt, 'S') AS s_cnt
FROM table_x
, cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= (
SELECT MAX (s_cnt)
FROM got_s_cnt
, got_pattern AS
SELECT s.x_id
, s.txt
, c.n
, REGEXP_SUBSTR ( REPLACE ( SUBSTR ( txt
, INSTR (s.txt, 'S', 1, c.n)
, 'SA*[^A]'
) AS pattern
FROM got_s_cnt s
JOIN cntr c ON c.n <= s.s_cnt
SELECT x_id
, txt
, pattern
, COUNT (*) AS cnt
FROM got_pattern
WHERE pattern IS NOT NULL
GROUP BY x_id
, txt
, pattern
ORDER BY x_id
, pattern
;At the heart of this query is the call to REGEXP_SUBSTR:
REGEXP_SUBSTR ( x
, 'SA*[^A]'
)which is looking for:
S = the letter S
A* = the letter A, repeated 0 or more times
[^A] = anything except the letter A -
Return Code - Query for Multiple Rows as XML
Hi,
I'm executing an MSSQL stored procedure through the "Query for Multiple Rows as XML" activity in LiveCycle ES. I do this through a call statement such as this:
{ call MyStoredProc(?) }
This works great, the stored procedure always returns a record set (with or without records). I use this activity rather than "Call Stored Procedure" because I can transform the record set into XML right away within this activity. Unfortunately any exception arising from invoking this stored procedure cannot be handled within the workflow as this activity does not have an exception handler (lightning bolt). In an attempt to handle at least some exceptions we have decided to use try/catches within the stored procedures and return different error codes. Now the problem I am faced with is that there is no way to retrieve the returned code within any of the SQL activities. We don't want to have to write an execute script for each of these SQL calls. Is there any way to do this? Seems like I'm 95% there.
Thanks
NicThanks for the offer, unfortunately we would need something certified by Adobe.
Nic
Maybe you are looking for
-
Transfer photo iPhoto to Desktop
How do I transfer a photo on iPhoto to Desktop? Not as wallpaper but as a file. iPhoto 09.
-
How do I import my address book from MS Outlook and NOT OUTLOOK EXPRESS Thanks in advance
-
Hi I've used MSFT computers for years and finally bought an iMac. It has the Lion OS already loaded on it, but it didn't come with a disk one can use (if need be) to reload the OS. I hope the solution is not for one to buy a copy from the Apple store
-
I wanted to try the Oracle by Example - Oracle Database 10g on VMWare/RAC and it says get started, first download the VMWare software and then the VM that contains the Oracle environment with all the software you need already installed I have VMWare,
-
Auto PO for multiple line items
Hi All, I ma creating PO with refernce to PR with T.code ME59 but my problem is to create PO with PR for multiple items, Ex: I have PR with 4 line items now i want to create PO only for 1&4 line items, please let me know if it is possible or if possi