Returning duplicate rows only
Hi All,
I need a Query to get only duplicate rows from a table. It should print the duplicate rows the number of times .
it exists in the table.
Added some duplicate records in emp table
select count(*),empno,ename,job,mgr,hiredate,deptno from emp group by empno,ename,job,mgr,hiredate,deptno
COUNT(*) EMPNO ENAME JOB MGR HIREDATE DEPTNO
2 7782 CLARK MANAGER 7839 09-JUN-81 10
5 7844 TURNER SALESMAN 7698 08-SEP-81 30
3 7698 BLAKE MANAGER 7839 01-MAY-81 30
1 7900 JAMES CLERK 7698 03-DEC-81 30
1 7654 MARTIN SALESMAN 7698 28-SEP-81 30
1 7788 SCOTT ANALYST 7566 19-APR-87 20
1 7566 JONES MANAGER 7839 02-APR-81 20
6 7521 WARD SALESMAN 7698 22-FEB-81 30
5 7369 SMITH CLERK 7902 17-DEC-80 20
4 7934 MILLER CLERK 7782 23-JAN-82 10
1 7499 ALLEN SALESMAN 7698 20-FEB-81 30Count(*)>1 are having duplicates
Filter this with condition Count(*)>1
select count(*),empno,ename,job,mgr,hiredate,deptno from emp group by empno,ename,job,mgr,hiredate,deptno having count(*)>1
COUNT(*) EMPNO ENAME JOB MGR HIREDATE DEPTNO
2 7782 CLARK MANAGER 7839 09-JUN-81 10
5 7844 TURNER SALESMAN 7698 08-SEP-81 30
3 7698 BLAKE MANAGER 7839 01-MAY-81 30
6 7521 WARD SALESMAN 7698 22-FEB-81 30
5 7369 SMITH CLERK 7902 17-DEC-80 20
4 7934 MILLER CLERK 7782 23-JAN-82 10Edited by: Lokanath Giri on २४ जनवरी, २०१२ १०:४६ पूर्वाह्न
Similar Messages
-
Hi. I'm working on this query, and I'm having problems. When I add an inner join, I start getting multiple rows returned.
What I want returned is ONLY the first row below, but I'm instead getting both rows (which are identical).
SALESMAN_NO | CUSTOMER_NO | ORDER | SALES | COGS | MARGIN
97 | 1306969000 | 00477023 | 517.40 | 298.20 | 219.18
97 | 1306969000 | 00477023 | 517.40 | 298.20 | 219.18
Here's my query. And when I add the inner joins, I get the 2nd row above. If I run the SAME query without the inner joins, I get the 1 and only 1 row - which is what I'm trying to get to. Getting this 2nd row is screwing up the SUM functions I'm ultimately trying to use.
SELECT
SOE.SALESMAN_NO AS [SALESMAN],
SOE.CUSTOMER_NO AS [CUSTOMER #],
(SOE.SALE_ORDER_NO) AS [ORDERS],
(SOE.SALES_AMT/100) AS [SALES],
(SOE.COST_GOODS_SOLD/100) AS [COGS],
((SOE.SALES_AMT/100) - (SOE.COST_GOODS_SOLD/100)) AS [MARGIN]
FROM
SOE_HEADER SOE
INNER JOIN CUST_NAME CUST
ON SOE.CUSTOMER_NO = CUST.CUSTOMER_NO
INNER JOIN OUTSIDE_SALES OUTSIDE
ON CUST.SALESMAN_NO = OUTSIDE.SALESMAN_NO
WHERE
SOE.SALESMAN_NO <> '83'
AND SOE.TYPE_OF_ORDER = '00'
AND SOE.ORDERS_STATUS = '06'
AND SOE.DATE_OF_ORDER > 20080101
AND SOE.TYPE_OF_FRGHT IN ('13','14')
AND SOE.CUSTOMER_NO = '1306969000'
I've looked at the data and at this query for about an hour now, and need some help. Thanks.If you want to get the distinct rows only in this SELECT then you may use DISTINCT. ie replace the table with a query
,(Select Distinct SALESMAN_NO,CUSTOMER_NO, ORDER SALES ,COGS , MARGIN From YourTableName) AS AliasName
Check this too
Find and/or Delete Duplicate Rows
http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=DuplicateRows&referringTitle=Home
Madhu
SQL Server Blog
SQL Server 2008 Blog -
Crystal report returning duplicate rows - Linking issue?
Hello,
I know this is a commonly brought up issue - that duplicate rows are returned in Crystal reports for various reasons. In a lot of instances, where it's only a single row of data per case that I'm looking for, I'll move them to their own group. But that solution doesn't work here.
The tables and links used in the simple report I have are illustrated in the attached "Report Database Expert Links.jpg" file, and the conditions and report fields required as as follows:
Select Expert conditions:
{CLAIM_PERIODS.CPE_START_DATE} < Today and
{CLAIM_PERIODS.CPE_END_DATE} > Today and
{CLAIM_ROLES.CRO_START_DATE} < Today and
IsNull({CLAIM_ROLES.CRO_END_DATE})
Report Design fields (in Details section):
CLAIMS.CLA_REFNO, CLAIM_ROLES.CRT_CODE, PARTIES.PAR_PER_FORENAME, PARTIES.PAR_PER_SURNAME
So what this report is to do:
It looks for benefit claims which are live (have a CLAIM_PERIODS.CPE_START_DATE prior to today, and CLAIM_PERIODS.CPE_END_DATE after today), and for these claims gives a breakdown of all people in the household (everyone associated with that claim, where CLAIM_ROLES.START DATE is prior to today, and end date is null - to pick out those who are currently active in the household).
This works fine otherwise, but the issue is that each live claim can have either one or two rows present in CLAIM_PARTS and CLAIM_PERIODS (so could satisfy my first two conditions twice). For claims with only a single claim part active, I get each household member listed once. But when they have two claim parts active, I get eveyone listed twice.
Is there a way - either in how I'm linking the tables up, or how I'm arranging the report design, that I can have every household member only appear once no matter how many related rows there are in CLAIM_PARTS and CLAIM_PERIODS?
Many thanks in advance,
Sami
P.S. I don't seem to be allowed to attache image files to my post, but have embedded the content instead:Thank you very much Don - this is a feature I wasn't aware of previously, and is a big step in the right direction for me. Really useful.
In the report mentioned, this sort of works. It works very well on individual fields - so I could just "Suppress If Duplicated" on the forename and then remove duplicates on that column when exported to Excel (or simply bring in a unique field such as the party reference number and do likewise).
However, is there a way to get Crystal to do this for me? So to suppress the whole line based on whether or not I'm suppressing this one field?
Just applying "Suppress If Duplicated" to all fields at once seems to have slightly unpredictable behaviour - not suppressing every field in the row. So I experimented a bit with using the "Suppress" tick to do this, then applying a formula to it. But the closest I can get for the formula is something like:
- {PARTIES.PAR_PER_FORENAME} = previous({PARTIES.PAR_PER_FORENAME}) and
{PARTIES.PAR_PER_SURNAME} = previous({PARTIES.PAR_PER_SURNAME}) and
Which will only compare the current row with previous. Is there a way to do the same comparison but with all previous rows? -
Report Builder 2.0 returning duplicate rows in query designer
Hi,
I have a query running off a model, when I explore the data in the model and in a standard sql table it returns one row for each record, which include a unique id for each which is correct.
When I go into report builder query designer, it shows duplicate rows for each record. I have removed and added fields to try and pin point why and the only reason i can come up with is that it runs fine until I add in a field thats varchar(255) or
varchar(max). This is when it starts to duplicate the records.
Can anyone tell me why it does this or point me in the direction of how to stop this. I can't edit the query in text to add DISTINCT so thats not an option.
Many thanks,
JJSJOK - I have found a partial answer. By Googling Report Builder and VARCHAR, I found another post which reported problems with the semantic query builder when the underlying table/view was returning columns of type VARCHAR(MAX).
On looking at the length setting for the data column in the DSV, this reported a length of 2,147,483,647 for this field. This is very odd because on querying the underlying table the largest length that I can find for this column is 191,086
(which is far larger than I would have expected - I am investigating this separately).
However, why should the Report Model think that this field contains such a large value?
Anyway, the other post that I found reported that they had solved their problem by converting the field to a VARCHAR (255). I tried this (by casting the column in my View to VARCHAR(255)) and this resolved the problem
- no more duplicate rows when adding this field to the query!!!
I also tried CASTING to TEXT and to VARCHAR(8000). The former did not resolve the problem; the latter did.
So I have a workaround but I don't understand why.
Can anybody explain why having a VARCHAR(max) column in my entity causes duplicate rows.
I suspect it is to do with the fact that for some reason the Report Model seems to think that there is an exceptionally long text string stored in this column in one of the rows but that again is a puzzle.
Thanks
Richard -
DB / Integation adapter returning duplicate rows on select [not all rows]
I am seeing some unusal behavior, we have Application adapter invoking BEPL and which invokes DB adapter to make a select call to ERP database. Select should return 2 different records, where as in the response xml it has same record [only first record] listed twice. On DB adapter wsdl, -"Return Single Resultset " is unchecked. Should this be checked? or is there any other reason why the first record may be cached. I have not seen this in other connectors, restarted server but still same issue. connector is in prod environment. Any help/ideas are welcome.
Edited by: user3622460 on Aug 5, 2009 10:23 PMCan you tell us more about the options you have selected in the Adapter to select the records ?
-
Hi All,
I am joining 3 tables:OWOR, WOR1 and IBT1. Following is the query:
SELECT OWOR.DOCNUM, OWOR.ITEMCODE, OWOR.CLOSEDATE, OWOR.DOCENTRY,
WOR1.ISSUEDQTY, WOR1.DOCENTRY,
IBT1.QUANTITY, IBT1.BATCHNUM
FROM OWOR INNER JOIN WOR1 ON OWOR.DOCENTRY = WOR1.DOCENTRY
IBT1 INNER JOIN ON OWOR.ITEMCODE = IBT1.ITEMCODE
WHERE OWOR.CLOSEDATE ='[%0]' AND OWOR.DOCNUM = CONVERT(INT,IBT1.BATCNUM)
O/P:
10 100 19.03.11 20 15 30 10
10 100 19.03.11 20 15 14 10
20 121 19.03.11 25 31 5 25
20 121 19.03.11 25 31 10 25
20 121 19.03.11 25 28 5 25
20 121 19.03.11 25 28 10 25
Note: I have tried Grouping on OWOR.DOCNUM, WOR1.DOCENTRY, also tried
Suppress with the combination of Prevoius
and Next. But could not succeed always the running totals of WOR1.ISSUEDQTY
and IBT1.QUANTITY are getting messed
up.
Please let me know if you have any suggestions.
Thanks,
Vineela.Hi Ian,
Sorry for the delay in replying, was stuck due to some Internet connectivity issues. Coming to the problem, I solved it myself, by changing the Running Total conditions when to evaluate and and when to reset. And my required O/P was:
Required O/P:
10 100 19.03.11 20 15 44 10
20 121 19.03.11 25 59 15 25
Thanx for your reply,
Vineela. -
Order by results in duplicates rows returned
Hi All,
Just got the following question that I could not understand at all. Let's assume we have a query like this:
select d.d_name, e.e_name
from dept d, emp e
where d.d_id = e.d_id
And this query returns 3 rows only:
IT JOHN
IT JAMES
ADMIN BILL
It was found that if the query was changed as:
select d.d_name, e.e_name
from dept d, emp e
where d.d_id = e.d_id
ORDER BY d.d_name, d.e_name
sometimes it returns as 4 rows instead of 3:
ADMIN BILL
IT JAMES
IT JAMES
IT JOHN
How this be possible?
This happened sometimes on windows platform.Hi All,
Just got the following question that I could not understand at all. Let's assume we have a query like this:
select d.d_name, e.e_name
from dept d, emp e
where d.d_id = e.d_id
And this query returns 3 rows only:
IT JOHN
IT JAMES
ADMIN BILL
It was found that if the query was changed as:
select d.d_name, e.e_name
from dept d, emp e
where d.d_id = e.d_id
ORDER BY d.d_name, d.e_name
sometimes it returns as 4 rows instead of 3:
ADMIN BILL
IT JAMES
IT JAMES
IT JOHN
How this be possible?
This happened sometimes on windows platform. -
I have an advancedTable (master-detail). In one instance the "advancedTable" object suppresses duplicate master records, but in another instance, duplicate rows are not suppressed. If I run the VO query associated with the advancedTable object, the query returns duplicate rows in both instances. Has anyone seen this before? I have also run the pages from JDev connecting to each instance and the same result is exhibited.
Thanks,
LC-- application release 11.5.10.2 (both environments)
-- database version 10.2.0.3 (stage) and 11.1.0.7 (dev)
-- OS - RHEL 5 (both evironments)
Both instances are not identical. The stage environment is RAC vs. dev which is not RAC.
Steps to reproduce:
Create an advancedTable in an advancedTable in JDev using a viewLink to establish the master-detail relationship. Run the page either from JDev connecting to each dev and stage environment directly. In addition to running local, I have also migrated all source to both the dev and stage instance. Run the page - in the dev instance, the results table displays only a subset of the rows (duplicate rows are removed - ie instead of 12 rows which is what the query returns both from executing the select statement in SQLPlus and by SOP vo.getRowCount() only 6 rows are displayed in the master table). However, when the same page is executed using the stage environment, all applicable rows are displayed - duplicates are not removed. This happens both from running the page locally and from logging into each respective application server.
Thanks,
LC -
When subquery returns multiple rows
I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
He says that when the subquery returns single row,,only then <=, >=, = should be used..
Why did they not use ANY,ALL or SOME operators.....When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
select c.description, s.section_no, c.cost, s.capacity
from course c, section s
where c.course_no=s.course_no
and s.capacity <= (select avg(capacity) from section)
and c.cost=(select min(cost) from course)Hi,
user11090588 wrote:
I have a doubt in this case. I follow Oracle SQL by example book and I find that "<=" is used in this query.
He says that when the subquery returns single row,,only then <=, >=, = should be used..
Why did they not use ANY,ALL or SOME operators.....If the sub-query returns no more than 1 row, then it doesn't matter which, if any, of the keywords ANY, ALL or SOME you use: they all give the same results. Only when there are 2 or more rows can it matter if you're doing the comparison to any, all or some of the rows.
When I use ANY,ALL ,,,it gives me an error "Invalid Relational operator"...... Please help
select c.description, s.section_no, c.cost, s.capacity
from course c, section s
where c.course_no=s.course_no
and s.capacity <= (select avg(capacity) from section)
and c.cost=(select min(cost) from course)If the problem occurs when you use ANY or ALL, why not post a query where you use ANY or ALL?
Post a complete script that people can use to re-create the problem and test their ideas. That includes CREATE TABLE and INSERT statements for your tables (unless you can show the problem using commonly available tables, like those in the scott schema).
Always say which version of Oracle you're using.
I can't reproduce the problem. I don't get any error using ANY, ALL, SOME or nothing before either sub-query:
SELECT d.deptno
, e.ename
, e.sal
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
WHERE e.sal <= ANY (
SELECT AVG (sal)
FROM scott.emp
AND d.deptno = SOME (
SELECT MIN (deptno)
FROM scott.dept
;Output from the query above:
` DEPTNO ENAME SAL
10 MILLER 1300I'm using Oracle 10.2.0.1.0.
Don't worry too much about ANY, ALL or SOME before sub-queries. I've never seen them used outside of a textbook (or questions like this, taken from a textbook). In real life, nobody uses them.
Someone once showed me any example where one of these actually would be useful if you didn't have analytic functions, but I didn't note what it was, or where I saw it. Analytic functions were introduced in Oracle 8.1, so that's only of historical interest now. -
Duplicate rows returned by contex index
Hi
I have a context index - locally partitioned with concatenated datastore.
When I run a query on this it gives me duplicate rows (But for some rare cases only).
Is this a bug in Oracle text?
The table is partitioned on column norm_state_query - This query gives a duplicate -
select rowid
from mv_borrower_branch_details
where contains ( norm_state_query, '( ( (fuzzy(${TATA},60,20,n) OR fuzzy(${PGIMENTS},60,20,n) OR fuzzy(${TATAPGIMENTS},60,20,n)) within norm_concat_name ) ) and ( ( ({43} OR fuzzy(${CHOWRINGHEE},60,20,n) ) within norm_concat_address ) )', 1 ) > 0
and norm_state_query = 'WEST BENGAL'
AAAKOGAAPAAAETMAAQ
AAAKOGAAPAAAETMAAQ
Thanks and regards
PratapHave you changed the partition definitions since you first created the index?
Maybe that could cause the problem.
Otherwise, it does sound like a bug. Please contact support so they can work
through it with you. -
Returning two rows with one column containing only one place
Dear all;
I have a query that returns two rows similar to this below
ID PLACE PROGRAM
A NEWYORK PROGRAM A
A NEWYORK PROGRAM B
I would like this instead
ID PLACE PROGRAM
A NEWYORK PROGRAM A
PROGRAM B
All help is appreciated. Thank you.Edited by: user13328581 on Mar 22, 2011 11:52 AMuser13328581 wrote:
WOW...THanks a lot Solomon, I have never used partitions and row_number in such a manner...can you please explain your logic.Sure:
row_number() over(partition by id order by place,program)This will take all rows returned by the query andsplit them into buckets (partitions) by id. Inside each bucket it will order rows by place and program and assign them row numbers. So for each ID row number 1 will be row with first (alphabetically) place first programt. And this is the row where we want ID to show up. That is why we wrap the above analytic function in CASE statement which will do exactly that. Now:
row_number() over(partition by id,place order by program)does pretty much the same just bucket is ID and PLACE combination. So for each such combination we want to show only for the first (alphabetically) programt.
Now notice in ORDER BY clause I prefix ID and PLACE with table alias. You must do it since otherwise query alias ID and PLACE will take precedence resulting in wrong sort order (remember we nulled all ID and PLACE except for row number 1).
SY. -
Duplicate rows showing up in a table on the UI
Hi All,
We have a VO that returns 6 rows in a table on the UI. The rows become editable when a checkbox(a column in the table) is selected.
On running it, sometimes we are getting 12 rows on the UI such that the first 6 rows are shown again in the table in the same order.
When changes are made to this table and saved, only 6 rows are saved in the database table. Also, if 1 row is selected and the duplicate row of this row is not selected, then if we go to some other page and come back, the row that was selected earlier, will be unselected. If both the rows of same values are selected, only then the changes will be saved.
The VO query has 2 tables. Checked data in both of these tables and executed the query too, but did not find any data issue. Also, we are having an order by clause in the query and the data in the table is not showing up in order.
This is not occurring consistently but occurring for long durations.
Can anybody fix this?
Thanks,
SakshiDo you still have the "Music Video" Smart Playlist in iTunes? If you right click on a video file, which normally shows up under "Movies" you can pick the video type of Movie, Music Video, or TV Show. When you select "Music Video" the video file drops out of the Movies section and if the Music Video playlist is present will show up there.
You might have deleted that playlist so it wouldn't be on the iPod either.
So create a Smart Playlist where the rule is Video Kind IS Music Video...
Patrick -
How to Create primary key index with duplicate rows.
Hi All,
While rebuilding an index on a table , I am getting error that there are duplicate rows in a table.
Searching out the reason led me to an interesting observation.
Please follow.
SELECT * FROM user_ind_columns WHERE table_name='SERVICE_STATUS';
INDEX_NAME TABLE_NAME COLUMN_NAME COLUMN_POSITION COLUMN_LENGTH CHAR_LENGTH DESCEND
SERVICE_STATUS_PK SERVICE_STATUS SUBSCR_NO_RESETS 2 22 0 ASC
SERVICE_STATUS_PK SERVICE_STATUS STATUS_TYPE_ID 3 22 0 ASC
SERVICE_STATUS_PK SERVICE_STATUS ACTIVE_DT 4 7 0 ASC
SERVICE_STATUS_PK SERVICE_STATUS SUBSCR_NO 1 22 0 ASC
SELECT index_name,index_type,table_name,table_type,uniqueness, status,partitioned FROM user_indexes WHERE index_name='SERVICE_STATUS_PK';
INDEX_NAME INDEX_TYPE TABLE_NAME TABLE_TYPE UNIQUENESS STATUS PARTITIONED
SERVICE_STATUS_PK NORMAL SERVICE_STATUS TABLE UNIQUE VALID NO
SELECT constraint_name ,constraint_type,table_name,status,DEFERRABLE,DEFERRED,validated,index_name
FROM user_constraints WHERE constraint_name='SERVICE_STATUS_PK';
CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME STATUS DEFERRABLE DEFERRED VALIDATED INDEX_NAME
SERVICE_STATUS_PK P SERVICE_STATUS ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED SERVICE_STATUS_PK
1. Using index scan:
SELECT COUNT (*)
FROM (SELECT subscr_no, active_dt, status_type_id, subscr_no_resets
FROM service_status
GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
HAVING COUNT (*) > 1) ;
no rows returned
Explain plan:
Operation OBJECT Name ROWS Bytes Cost OBJECT Node IN/OUT PStart PStop
SELECT STATEMENT Optimizer MODE=CHOOSE 519 K 14756
FILTER
SORT GROUP BY NOSORT 519 K 7 M 14756
INDEX FULL SCAN ARBOR.SERVICE_STATUS_PK 10 M 158 M 49184
2. Using Full scan:
SELECT COUNT (*)
FROM (SELECT /*+ full(s) */ subscr_no, active_dt, status_type_id, subscr_no_resets
FROM service_status s
GROUP BY subscr_no, active_dt, status_type_id, subscr_no_resets
HAVING COUNT (*) > 1) ;
71054 rows returned.
Explain Plan:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE 1 24123
SORT AGGREGATE 1
VIEW 519 K 24123
FILTER
SORT GROUP BY 519 K 7 M 24123
TABLE ACCESS FULL ARBOR.SERVICE_STATUS 10 M 158 M 4234
Index SERVICE_STATUS_PK is a unique and composite primary key VALID index. And the constraint is ENABLED and VALIDATED still having duplicate rows in table.
How it is possible?
Is it an Oracle soft Bug??
Regards,
Saket Bansalsaket bansal wrote:
Values are inserted as single rows inserts through an GUI interface.And you still claim to have over 71K duplicate records, without the GUI getting any kind of errors?
That does not add up and can only be explained by a "bug".
I tried inserting a duplicate record but failed.
SQL> insert into service_status (select * from service_status where rownum <2);
insert into service_status (select * from service_status where rownum <2)
ERROR at line 1:
ORA-00001: unique constraint (ARBOR.SERVICE_STATUS_PK) violatedAre you really sure there is no other way data in this table is populated/manipulated in bulk? -
Duplicate Rows In Oracle Pipelined Table Functions
Hi fellow oracle users,
I am trying to create an Oracle piplined table function that contains duplicate records. Whenever I try to pipe the same record twice, the duplicate record does not show up in the resulting pipelined table.
Here's a sample piece of SQL:
/* Type declarations */
TYPE MY_RECORD IS RECORD(
MY_NUM INTEGER
TYPE MY_TABLE IS TABLE OF MY_RECORD;
/* Pipelined function declaration */
FUNCTION MY_FUNCTION RETURN MY_TABLE PIPELINED IS
V_RECORD MY_RECORD;
BEGIN
-- insert first record
V_RECORD.MY_NUM = 1;
PIPE ROW (V_RECORD);
-- insert second duplicate record
V_RECORD.MY_NUM = 1;
PIPE ROW (V_RECORD);
-- return piplined table
RETURN;
END;
/* Statement to query pipelined function */
SELECT * FROM TABLE( MY_FUNCTION ); -- for some reason this only returns one record instead of two
I am trying to get the duplicate row to show up in the select statement. Any help would be greatly appreciated.Can you provide actual output from an SQL*Plus prompt trying this? I don't see the same behavior
SQL> SELECT * FROM V$VERSION;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> CREATE TYPE MY_RECORD IS OBJECT(MY_NUM INTEGER);
2 /
Type created.
SQL> CREATE TYPE MY_TABLE IS TABLE OF MY_RECORD;
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION MY_FUNCTION
2 RETURN MY_TABLE
3 PIPELINED
4 AS
5 V_RECORD MY_RECORD;
6 BEGIN
7 V_RECORD.MY_NUM := 1;
8 PIPE ROW(V_RECORD);
9
10 V_RECORD.MY_NUM := 1;
11 PIPE ROW(V_RECORD);
12
13 RETURN;
14 END;
15 /
Function created.
SQL> SELECT * FROM TABLE(MY_FUNCTION);
MY_NUM
1
1 -
I have five tables(A,B,C,D,E), and I am trying to check for duplicate rows in all the tables, I tried using inner join, but the first three join did not return any table. is there another way.the tables only have two columns , the email(different values)
and authour (which is the same person in the table)
when i tried
select * from TABLE A
INNER JOIN TABLE B
ON TABLEA. EMAIL = TABLEB.EMAIL
INNER JOIN TABLEC
ON TABLEA.EMAIL=TABLEC.EMAIL
it came back with no result, the other way I am thinking is to unioun all all the tables and try to use count and group by ,but this will only show me the duplicates and not the authours
please any other wayit came back with no result, the other way I am thinking is to unioun all all the tables and try to use count and group by (but I could not insert my result in a new table)
please any other way
I dont understand your point here...Are you trying the below?
Create Table T1(name varchar(50),Email Varchar(50))
Insert into T1 Values('SQL','[email protected]'),('.NET','[email protected]')
Create Table T2(name varchar(50),Email Varchar(50))
Insert into T2 Values('Server','[email protected]'),('BizTalk','[email protected]')
Create Table T3(name varchar(50),Email Varchar(50))
Insert into T2 Values('Sql','[email protected]'),('server','[email protected]')
;With cte as
(Select * From T1
Union All
Select * From T2
Union All
Select * From T3)
Select name,email, count(1) From cte Group by name , email having count(1)>1
Drop table T1,T2,T3
I was able to insert the union product in a table, and i used this
SELECT EMAIL,AUTHOR,COUNT(EMAIL) AS AMOUNT FROM ALLEMAIL
GROUP BY AUTHOR,EMAIL
ORDER BY AMOUNT DESC, email desc
but its showing the email and the count but its appearing like the duplicate is only associated with one authour
Maybe you are looking for
-
2 year old iPhone 3GS battery lasts only 4 hours?
Hi, My iPhone 3GS (bought in July 2010) battery lasts from 4-6 hours with light usage (no 3G, 5 mins of web browsing, 15 mins of music playback). It is definitely not an issue of iOS 5 as it was giving much better battery life even after the update.
-
TS1717 iTunes will not open- please help!
My iTunes will not open. I've tried uninstalling and reinstalling, but the same message keeps showing up when I try to open iTunes. The error reads "C\Windows\system32\dssenh.dll is either not designed to run on Windows or it contains an error. T
-
Iphoto Problem [ver 8.1.2]
Hello, i have reed the posts inside the IPHOTO discussion but i cant solve anyway my problem. When i start Iphoto Program error message appear. Process: iPhoto [352] Path: /Applications/iPhoto.app/Contents/MacOS/iPhoto Identifier:
-
Error when opening document with ECL control: INVALID_DATA
Hi Gurus, I've tried to search the net for this problem but could not find anything and I'm stuck now. Description: we're using ECL to view attached documents (to POs etc.) which are stored through ArchiveLink on the content repository. when we try t
-
How do I uninstall Mavericks and go back to Mountain Lion
Any ideas? Can't find it on App Store anymore.