Obtaining unique records
I am trying to build a query using two tables. One is a table called sanctuary lakes cleaning data. The other one is called Faulire data. In cleaining table there are four years of cleaning records for each pit. I want to find the performance of these cleaned pits using failure table. Each failure date should have only one correspoding cleaning date. I wrote the following query. This query works. But it gives duplicate data. Some of the records will show two cleaning dates for a failure.
My query is like this.
SELECT DISTINCTROW [Sanctuary Lakes cleaning data].PIT, [Sanctuary Lakes cleaning data].[Cleaned Year], [Sanctuary Lakes cleaning data].[Cleaning Date], [Sanctuary Lakes cleaning data].[SR NO], [Failure data table].[Failure Year], Min([Failure data table].Failure_date) AS MinOfFailure_date, [Failure data table].[Failure SR no]
FROM [Failure data table] LEFT JOIN [Sanctuary Lakes cleaning data] ON [Failure data table].Pit = [Sanctuary Lakes cleaning data].PIT
GROUP BY [Sanctuary Lakes cleaning data].PIT, [Sanctuary Lakes cleaning data].[Cleaned Year], [Sanctuary Lakes cleaning data].[Cleaning Date], [Sanctuary Lakes cleaning data].[SR NO], [Failure data table].[Failure Year], [Failure data table].[Failure SR no]
HAVING (((Min([Failure data table].Failure_date))>Min([Sanctuary Lakes cleaning data]![Cleaning Date])))
ORDER BY [Sanctuary Lakes cleaning data].PIT;
My results are as follows:
PIT Cleaned Year Cleaning Date SR NO Failure Year Failure_date Failure SR no
1-08 2007/08 16-Oct-07 213458 2011/12 13-Aug-11 414984
1-08 2007/08 16-Oct-07 213458 2011/12 25-Jun-12 478589
1-08 2009/10 19-May-10 313497 2011/12 13-Aug-11 414984
1-08 2009/10 19-May-10 313497 2011/12 25-Jun-12 478589
1-08 2010/11 22-Feb-11 379081 2011/12 13-Aug-11 414984
1-08 2010/11 22-Feb-11 379081 2011/12 25-Jun-12 478589
1-08 2011/12 17-Apr-12 458430 2011/12 25-Jun-12 478589
I want the following results.
PIT Cleaned Year Cleaning Date SR NO Failure Year Failure_date Failure SR no
1-08 2010/11 22-Feb-11 379081 2011/12 13-Aug-11 414984
1-08 2011/12 17-Apr-12 458430 2011/12 25-Jun-12 478589
How can I modify my query?
Please help.
thanks
Nish
there is nothing wrong with distinct , i just want know alternative approch.
thank u very mach.
Similar Messages
-
How to show all records (instead of unique records) in OBIEE Answers
I am a newbie of OBIEE and have below question.
The fact table has 3 fields:
ID (Primary Key)
Status (either 'open' or 'close')
Amount
There are 100 records in the fact table. When I drag the column Status into the Answers, the result returned is 2 records, 'open' and 'close'. Thus, seems Answers always returns unique records only.
Can I achieve disabling such Answers feature such that all records will be shown? For above example, can the result returned all 100 records of either 'open' or 'close' ??
Thank you very much.Hi,
OBIEE is an analytical tool, it is there to help people see the value of numeric facts against one or more textual attributes. With that in mind OBIEE will always aggregate to the highest possible level when returning the results to you. In your case the highest level is status. If you include another column wich breaks the data down further then you will see it aggregated at that level. If you want to see individual records then you need to add a column which is unique for each record, usually you can use the column holding the identifier of the row from the source system, generally this is called Integration Id.
Edit: After reading your post again, just add the ID column in your request and voila.
Regards,
Matt
Edited by: mod100 on 13-Oct-2009 23:39 -
Help needed to get unique record from an internal table
Hi Everybody,
I have to get unique record from an internal table. i know we can use read statement with key condition .
But the problem is i have to use some relational operators like GE or LE.
eg
read table itab into wa with key width GE itab-widthfrom
width LE itab-widthto
machno eq itab-machno.
Its giving me error when I use the operators GE , LE.( I think since it can't find a unique record with those relational
operators in the with key statement)
Is there any other way to get unique record from internal table without using the loop?
Thanks,
SunnyUsing the read statement you will need some kind of loop. For example.
DO.
READ TABLE......
WITH KEY ......
READ = SPACE
IF SY-SUBRC EQ 0
TABLE-READ = 'X'.
MODIFY TABLE
ADD 1 TO W_FOUND.
ELSE
EXIT.
ENDIF
ENDDO.
IF W_FOUND EQ 1.
...record is unique.
ENDIF. -
Hello
I put all of the Info Objects avaiable in Info Source and my ODS still aggregates the data. How to make the records unique for ODS? I mean, is any possibility to add the unique identifier, generated / populated by Update Rules?
Kooyot.HI kooyat--
Under ODS settings you do have a checkbox with Unique records,..
you enable that check box and check whether it brings the Uniques records or not.
If this doesn't you have to go for an unique identifier in Update rules.
Regards,
VIshwa. -
Alternative to find unique records with 60 character in selection string.
Hi,
We have to find out the values from the Infoobject. When we try to display data from an master object, the maximum length of selection it accepts 45 characters only but we need to input data around 60 characters in selection.
Thing we tried:
1. Selecting complete data without any condition but it did not work due to large volume of data.
2. We tried to extract data from RSA3 but it did not work due to large volume of data.
Please suggest me alternative to find unique records with 60 character in selection string.
Regards,
Himanshu Panchal.This sounds a bit strange. Are you perhaps mistakenly storing text data incorrectly as the primary key of the master data? I can't think of any actual data that is that length to ensure usinqueness - even GUIDs are maximum 32 characters - but GUIDs don't count as actual "readable" data although you do need to be able to select it from time to time. Perhaps you have a super secure password hash or something like it ?
Also are you expecting to have a unique single record returned by your selection? To do this would in general REQUIRE that ALL the data is read because master data is not stored in the DB sorted by the data itself, but stored instead sorted by the it's SID.
When you say you are selecting data from master data, which master data tables are you using? I have been able to select data from very large MD table (15 million unique records) using SE16 with no problems. Just enter the table name, and before you execute just count the number of records - it helps to know what you want to end up with.
Have you tried using wild cards (the *) to preselect a smaller number of records : * a bit of your 60 character string *
If you are trying to select from a non-key field you will encounter performance issues, but you can still use the wildcards, and get a result.
Don't use RSA3 it was designed to make selections and group them into datapackets. It's not the same as selecting directly on the table in SE11 or SE16 -
I've created a dynamic table that retrieves multiple records
for an individual. I've included a submit button in each line
created with the unique record ID as hidden data to be sent for
selecting a update page, but the data I get is all of the unique
records ID's, like 45,46,48,49,50 where I only wanted #46. The
example in the workbook shows an href call to select a particular
record. Is it possible to use either a submit key or a radio button
to select a certain record to update? I have additional data I need
to pass along to the next page so an href pointer won't really
work. What am I doing wrong?If you don't want to use an HREF pointer, then you will need
to use some JavaScript to let you know which record the user has
selected. Instead of using a type="submit", use a type="button" and
then include the following onClick statement in the tag:
onClick="document.form1.selectID=#rs_AP_Cert_Quest.Key#;
document.form1.submit();"
Then include a hidden form element named selectID at the
bottom of the page.
I probably would use a function instead of coding it directly
in case I needed to add some more functionality and it would get to
messy to do all of the JS inline. But the above code will get you
running. -
Query Unique Records WITH ROWID
Hi All,
I have 2 columns which returns records like this Say Column A and Column B.
A B
1 1
1 1
2 2
2 2
3, 3
I need only distinct records from these columns. So i executed DISTINCT Clause in my query and it returned unique records. Issue is I need to execute a query like this i.e compulsorily use ROWID in my select list.
i.e SELECT DISTINCT ROWID A, B from TEST;
But this query we will give duplicated records only when we give rowid, how to achieve a output like this using rowid in the column select list of my query.
A B
1 1
2 2
3, 3
Please Help.
Thanks in advance.If you want just one rowid for each (a, b) couple:
SQL> select a, b, min(rowid)
2 from y
3 group by a, b;
A B MIN(ROWID)
1 1 AAAfoUAAEAAA7T0AAA
2 2 AAAfoUAAEAAA7T0AAC
3 3 AAAfoUAAEAAA7T0AAEIf you want all rowid's for each couple:
SQL>select a, b, rtrim(extract(xmlagg(xmlelement("a",rowid||',')),'//text()'),',') rowids
2 from y
3* group by a, b
A B ROWIDS
1 1 AAAfoUAAEAAA7T0AAA,AAAfoUAAEAAA7T0AAB
2 2 AAAfoUAAEAAA7T0AAC,AAAfoUAAEAAA7T0AAD
3 3 AAAfoUAAEAAA7T0AAEThanks Buga for posting sample data ;)
Max
[My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/] -
Extracting unique records from two different tables record
Hello,
In the following code of two different tables www.testing.com exists in both tables. I want to compare two different columns of the two different tables to get unique records.
SQL> select unique(videoLinks) from saVideos where sa_id=21;
VIDEOLINKS
www.testing.com
SQL> ed
Wrote file afiedt.buf
1* select unique(picLinks) from saImages where sa_id=21
SQL> /
PICLINKS
test
test14
www.hello.com
www.testing.comThanks & best regardsUnfortunatly you didn't mention the expected output. I guess it would be the one line
"www.testing.com"
in that case simply join the two tables.
select *
from saVideos v
join saImages i on i.sa_id = v.sa_id and i.picLinks = v.videoLinks
where v.sa_id=21;If needed then you could change the select list to retrieve only distinct values.
select unique v.sa_id, v.videolinks
from saVideos v
join saImages i on i.sa_id = v.sa_id and i.picLinks = v.videoLinks
where v.sa_id=21;I usually avoid distinct/unique whereever possible. This requires the database to do a sort and makes the query slow.
Edited by: Sven W. on Feb 10, 2011 1:55 PM -
Picking unique records from huge set of records
Hi db experts,
Could anyone help me in having a query which is based on partitioned table with 400,00,000 records each day . It has member number unique and I want to pick unique ones say for dates between 20-jan-2007 and 20-apr-2007.
How can I proceed to write query. Am expecting query which will only pull unique records in less possible time.
Thanks in advance
RavikanthThe table has 400 lakh records each day my mistake - I misread the original post.
Is this a one-off exercise or an ongoing requirement? What are you going to do with the data once you've got it - do you need more columns than the numbers? Do you have a feel for how many unique numbers there are per day and over the entire quarter?
The easiest way to do this would probably be to create an extract table (maybe a temporary one) and vary the query I posted to insert the unique numbers into this table for each day i.e. run it multiple times against a smaller data set. Then you can select the unique numbers from the extract table to get the finished set.
Of course, whether this is a viable solution depends on the answers to the questions I posed above. The more information you give us the easier it is for us to advise you.
Cheers, APC -
How to get a count of unique records
How do you get a count of unique records? Looking only for one number, not a list..so if the data is:
ID
===
1234
1234
1234
1236
1236
1237
Then, the count total will be one field called 'ID' with the value '3' in it..
All I know how to do is get a count that will count all records, or do it in two queries. Looking to do this in one query statment..
Thanks..Just a small clarification...
Concatenation could potentially give wrong result, depending on the data.
For example...
sudhakar@ORCL>ed
Wrote file afiedt.buf
1 with t1 as
2 (select 'AA' c1, '101' c2 from dual union
3 select 'AA1' c1, '01' c2 from dual union
4 select 'AA101' c1, null c2 from dual union
5 select 'BB2' c1, '345' c2 from dual union
6 select 'AA101' c1, null c2 from dual union
7 select 'BB2' c1, '345' c2 from dual union
8 select 'BB234' c1, '5' c2 from dual
9 )
10* select count(distinct c1 || c2) from t1
sudhakar@ORCL>/
2IMHO, the required answer will be...
sudhakar@ORCL>ed
Wrote file afiedt.buf
1 with t1 as
2 (select 'AA' c1, '101' c2 from dual union
3 select 'AA1' c1, '01' c2 from dual union
4 select 'AA101' c1, null c2 from dual union
5 select 'BB2' c1, '345' c2 from dual union
6 select 'AA101' c1, null c2 from dual union
7 select 'BB2' c1, '345' c2 from dual union
8 select 'BB234' c1, '5' c2 from dual
9 )
10* select count(distinct c1 ||'.'|| c2) from t1
sudhakar@ORCL>/
5
sudhakar@ORCL>vr,
Sudhakar B. -
Filters, copy, delete and unique records
I use a lot the Unique records filter in Excel, anyone knows if it's available on Numbers???,
Additionally, when I filter a list and I try to copy the filtered results, I copy the whole table again, and when I delete filtered rows, Numbers delete all the non-show rows that are between the filtered ones. How can I avoid it?Hi..
Ex: U have ITAB1 - Email is one of the field
1. SORT ITAB1BY EMAIL.
2. DECLARE WF_EMAIL TYPE EMAIL.
LOOP AT ITAB1.
AT FIRST.
WF_EMAIL = ITAB1-EMAIL.
ENDAT.
IF NOT WF_EMAIL = ITAB1-EMAIL.
APPEND ITAB3. " passing unique entry
WF_EMAIL = ITAB1-EMAIL.
ENDIF.
* pass the values to ITAB2 and APPEND for duplicate all records
ENDLOOP.
Hope this Helps,
Nag
Edited by: Naga Mohan Kummara on Dec 14, 2009 11:46 AM -
Counting Unique Records: very urgent
Hi,
I have to create a query for which i have to count the unique records appearing for a particular selection. For that i created a CK and in its agregation set Count all values <> 0 For customer. we are having Modality in my rows and CK in column. Now what happens if for 4 different records there is one customer then output appears one against that modality but it should show 4. As such there is no unique field in the cube that i can count. But we have maintined a Count key figure against each record in the cube that has value 1 for each row. But as it is a Key figure i cannot use it in aggregation. Is there any way to solve this situation....
Please help. Its very urgent..
Thanks
Points assured.Hello,
Use Exception Aggregation as Customer. It will work.
Crearte CKF
Assign 1 initial value
Count all properties
Exception aggretion is Customer.
I think It should work
Thanks,
Kishore
@KR -
Retriving unique records and insert into cust and cust_det table
Hi,
uniq Table : EMP
column name
name
addr
city
addr1
city1
EMP table contains only unique records.
we neet to get the records from emp and insert into cust and cust_det accordingly
table : cust
empno : auto generated
name
addr
tabel : cust_det
empno : refer from cust
addr1
city1
plese help me to do this.user10069916 wrote:
can some one help me to resolve this plz. bit urgent..My boss says my work is more urgent than yours.
As I said, please read: {message:id=9360002} (especially point 2)
If you post sufficient information, then people can help you. the better the information you provide the faster people will be able to help... but still, if it's "urgent" then we can only assume you have a live production system that is failing, in which case you need to raise an SR with Oracle Support, as the forums are not the place for logging "urgent" production system issues. -
Debatch unique records only, BizTalk 2010
Hi all,
I have a flat file coming onto BizTalk that contains multiple duplicate rows. I want to debatch to XML, however only keep the unique records. Is there a way of doing this without using a custom pipeline component?
Thanks in advance.
GilesBUse a map and with custom XSLT in your map you can filter the records eliminating the duplicate records (Muenchian), then in orchestration by calling the Receive pipeline you can debatch the message. Check the following references for eliminating the duplicate
records in maps:
http://social.msdn.microsoft.com/Forums/en-US/760d5bd6-aa97-4fff-a4c8-706f86bda7b5/eliminate-duplicate-records-in-map-instance?forum=biztalkgeneral
http://alamnaushad.wordpress.com/2012/02/24/filter-unique-records-using-biztalk-xsl/
And following is the reference for debatching the message in orchestration by calling the Receive pipeline
http://geekswithblogs.net/sthomas/archive/2005/06/16/44023.aspx
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
Hi,
How can i reduce time to count and display unique record from a table .
I have tested with DISTINCT but it takes more time to execute.
kindly give me optimize way to create query.You've posted nothing for us to work with, so start here I guess:
How to post a tuning request:
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long:
When your query takes too long ...
Maybe you are looking for
-
Slide to unlock no longer works in landscape view
Ipad is only a month old and the slide gives me difficulty in landscape view. Need to pull it 3 or 4. Times and still doesn't work sometimes. Is fine in portrait view. Tried to reset by pressing home and off switch, but no change. Any suggestions
-
After installing, whenever i try to open the application, it keeps popping up that some or the other .dll file is missing. When I install that particular .dll file and then again try to re open, it says that someother file is missing. It keeps coming
-
NHL Gamecenter Premium Upgrade
As a huge NHL fan, I use the NHL Gamecenter app quite a bit. I recently upgraded my phone to the LG G2, and now I can't seem to get any of the content that comes with the Premium upgrade that I believe I'm supposed to get for free as a Verizon custo
-
Revision: 23961 Revision: 23961 Author: [email protected] Date: 2012-06-15 04:42:44 -0700 (Fri, 15 Jun 2012) Log Message: Bug#3200562: New Flex Session Id generated while disconnect with streaming amf channel While invalidating session, make su
-
L505D said my Windows 7 is not genuine, how can I resolve it?
I bought loptop L505D-S5983 just 15 days ago in U.S. with Windows 7 Home Premium installed already with Win7 S/N number at the bottom of my laptop. But yesterday when I reboot the laptop, it prompt that the Win7 is not genuine and asked me to active