Distinct clause as part of EJB QL
Hi,
I am trying to perform a simple query which looks like following in ejb-jar.xml
<query>
<query-method>
<method-name>findBySecurityNumber</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT DISTINCT OBJECT(a) FROM LoanEntity a WHERE a.securityId = ?1
</ejb-ql>
</query>
In the SQL generated, I do not see the distinct clause being generated. Any ideas
as to what I am doing incorrectly?
This was a bug in SP 1, WL 6.1. But I am using SP2.
Thanks for your help
Mohit
Hi Mohit,
You aren't doing anything wrong. The generated queries don't contain a distinct clause
because it isn't portable. For example, Oracle will not allow the use of "SELECT
DISTINCT" in conjunction with a "FOR UPDATE" clause. For portablility, the EJB
container manually weeds out the duplicate results. You can, however, still can have a
distinct clause in your generated SQL by using the sql-select-distinct element of your
CMP deployment descriptor. This may give you better performance but be sure the
transaction your query executes in will not have an isolation level of
TRANSACTION_READ_COMMITTED_FOR_UPDATE or you will run into problems.
- Matt
Mohit Sehgal wrote:
Hi,
I am trying to perform a simple query which looks like following in ejb-jar.xml
<query>
<query-method>
<method-name>findBySecurityNumber</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT DISTINCT OBJECT(a) FROM LoanEntity a WHERE a.securityId = ?1
</ejb-ql>
</query>
In the SQL generated, I do not see the distinct clause being generated. Any ideas
as to what I am doing incorrectly?
This was a bug in SP 1, WL 6.1. But I am using SP2.
Thanks for your help
Mohit
Similar Messages
-
I found out issue distinct clause in query ,refcursor not returning rows
URGENT
hi the following procedure returns records but when i add distinct clause to (open v_refcursor for select )
i.e open v_refcursor for select distinct column1,column2 .......... in the procedure the procedure is not returning records. please help what is the issue here?
CREATE OR REPLACE procedure proc_shared_report3 (in_cust_id varchar2,in_user_array user_tab , in_acct_array acct_tab,in_report_pvlg_hier varchar2,in_fmt_pvlg_hier varchar2,v_refcursor OUT sys_refcursor)
is
BEGIN
if in_acct_array.count>0 and in_fmt_pvlg_hier is not null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null then
dbms_output.put_line('all are not null');
*open v_refcursor for select usr_id* from vw_get_user_profile where usr_id in (
SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2 WHERE
up1.usr_id=up2.usr_id and
up1.product_hierarchy=in_report_pvlg_hier and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND up1.usr_id in (select usr_id from vw_get_user_for_customer where
cust_id=in_cust_id)
and up1.usr_id Member Of in_user_array) AND acct_nb Member of in_acct_array);
/* if account list is null and rest all not null */
elsif (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is not null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null then
dbms_output.put_line('acc is null and rest are not null');
*open v_refcursor for select usr_id,usr_type_cd* from vw_get_user_profile where usr_id in(SELECT distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2 WHERE
up1.usr_id=up2.usr_id and
up1.product_hierarchy=in_report_pvlg_hier and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND up1.usr_id in (select usr_id from vw_get_user_for_customer where
cust_id=in_cust_id)
and up1.usr_id Member Of in_user_array);
/* if account list is null and format pvlg hierarchy is null */
elsif (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null
then
dbms_output.put_line('acc is null and format is null null');
*open v_refcursor for select usr_id,tmzon_cd* from vw_get_user_profile where usr_id in (
(SELECT distinct usr_id FROM vw_get_user_privileges WHERE product_hierarchy=in_report_pvlg_hier AND usr_id in (select usr_id from vw_get_user_for_customer where
cust_id=in_cust_id)
and usr_id Member Of in_user_array)) ;
/* if account list is not null and format pvlg hierarchy is null */
else -- If i get only one privilege and all other inputs then
dbms_output.put_line('acc list is not null and format pvlg is null');
*open v_refcursor for select usr_id,prod_shrt_nm* from vw_get_user_profile where usr_id in (
SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT distinct usr_id FROM vw_get_user_privileges WHERE
product_hierarchy=in_report_pvlg_hier AND usr_id in (select usr_id from vw_get_user_for_customer where
cust_id=in_cust_id) and usr_id Member Of in_user_array ) AND acct_nb Member of in_acct_array);
END IF;
END proc_shared_report3;
/Edited by: raj_fresher on Aug 12, 2009 8:50 AM
Edited by: raj_fresher on Aug 12, 2009 1:40 PMits like this ...... ?
You have to understand that without any testdata/ a reproducable testcase, all I can do is asking you to test some alternatives, I'm just guessing things from what I can make of your example, and hope you'll repost back any differences in a clear and concisive way.
What I didn't understand is why you're not just joining your tables/views instead of using inner queries.
Unfortunatly you're not providing any feedback on that, on the other hand you've narrowed down your problem to a specific part of your query? But you're not sharing why/what makes you decide to take that turn.
But: you're still using inner queries in your reply.
So, sorry, I cannot proceed/say anything useful unless you answer my previous post.
Because, there are still many other questions/doubts: I don't understand why you're not aliasing your columns properly, for example.
I don't know why you've suddenly switched to VW_GET_USER_cust_sa?
I don't know if you've tried the straight join instead of nesting queries?
And if you did, what's the problem?
Please read and understand this, so you'll get your answers by the speed of light the next time you've got a question or problem:
http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
And don't refrain from using that tag ;) -
Problem with performance of a query having order by, distinct clause
Hi,
I have a problem with queries having order by, distinct clause.
While its executing its taking lot of time. With DBMS_PROFILER identified the queries taking long time.
The table is having approximately 70 million rows.
Problem -1
select * from table_name order by col1;
select distinct col1,col2 from table_name;
Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.
Solution1:
Max parallel servers is 8.
select /* + parallel(table_name,8) */ * from table_name order by col1;
select /* + parallel(table_name,8) */ distinct col1, col2 from table_name ;
Solution-2:
select /* + first_rows */ * from table_name order by col1;
select /* + first_rows */ distinct col1, col2 from table_name ;
Problem-2
I am having a query with where condition on columns.
Select * from table_name where col1='value1' and col2!='value2';
Index created on col1 and col2.
As we no that not equal won't use index as it is a composite index it should use the lead column. but its not using the index.
Should i forcibly use index with hint or suggest me better solution.
Any help really appreciated.
Thanks in advanceunique wrote:
The table is having approximately 70 million rows.
select * from table_name order by col1;Do you really want 70,000,000 rows from your table without any restrictions ? And furthermore ordered output ? I honestly understand the slowness of that query.
Here i am having 2 solutions request to let me know whether i am right if not suggest me right solution.Who knows if you choosed the right solution. I would suggest to reconsider your query and the need of 70,000,000 returned rows.
Problem-2
I am having a query with where condition on columns.
Select * from table_name where col1='value1' and col2!='value2';Please, provide the explain plan, eventually the tkprof output could also help. And tables descirption AND indexes description.
And OS and Oracle version.
Nicolas. -
Avoid distinct clause in the query
hi i have a query from a single table using distinct clause and has columns (a,b,c,d,e,f,g,h,i)
eg: select distinct a,b ,c,d from table
where a<>0 and b<>0 and c<>0 and d<>0 and e=o and f=0 and g=0 and h=0 and i=0 ;
when i see the execution plan with out distinct... it performs a bit faster.
how do i remove distinct clause and make the query perform better
this particular query is used as inline view in my vieiw . it is used in from clause .
please suggest
second question.... iam getting bitmap index to rowid conversion ...is this good? does it hamper performance . how to avoid this?
regards
raj
Edited by: raj_fresher on Jul 17, 2009 7:48 AMHi Raj
what is e in the query ?It is the column name you provided yourself in your own unformatted example.
After 400+ posts I thought you would understand that it's not that hard to put this exact tag => (yes, 6 characters, 4 letters between 2 curly brackets) before and after your code examples or sample data or explain plans.
That way you maintain formatting and improve readability for us poor readers by magnitudes.
But, I'm sure you'll succeed as well as all the others who can.
I always look on the bright side.
Example:
Earlier this week another Raj also finally got enlightened about it, and his life has since then changed forever!
+He drives a Bentley now, you know+ ;) -
Distinct Clause missing on "Primary Key"
In our implementation, we have views and tables mixed physical Schema. For the views, obviously, they do not have to have 1 column as PK, but have a combination of columns to uniquely identify a record. Now when we use some of the views as dimension in our physical layer to do a join, it will automatically mark that joined column in the view as a "key" column, which makes sense.
Now, when we expose the very same column to the presentation, and then, do a query on that, it did not give use a distinct value of that column, instead, it give you 1 row per line. If I make a request by using columns with PK column from the same dimension table, it will not have a "Distnct" in the select statement , But if I put the PK column with other columns from a Fact table, it is then showing a "Distinct" clause in the select statement. In our situation, we need to have a distinct clause in the select statement, even there is no fact column involved.By definition your key column(s) defined in the Physical and Logical models must be unique. If you have multiple rows returned for your key when selecting from just the dimension table then your key is incorrect.
If you are saying when you join to the fact you see multiple rows, then check you have set your aggregate functions correctly on your fact measures. ie. SUM/COUNT etc...
Hope this helps. -
Distinct clause and query performance
Friends,
I have a query which returns results in 40 seconds without distinct clause and when I add distinct clause it takes over 2 hours.
I have verified following -
1. indexes/table statistics are up to date.
2. columns that are used in where clause but are not indexed have upto date column statistics
Any idea what could be the reason, explain plan shows that distinct clause has a very expensive cost.
Thanks
Query and explain plan is below
SELECT
DISTINCT -- with distinct 2hrs + and without 40 seconds
quote_by_dst.qte_hdr_stat_cd, quote_by_dst.qte_ln_cond_cd,
product.prod_nm, product.prod_id,
cs_ship_by_dst.bto_ds_cac_ownr_ud,
quote_by_dst.qte_csup_csup_am, cs_ship_by_dst.bto_ds_cac_nm,
product.spl_sht_nm,
product.prod_blg_un_fac_um
|| ' '
|| product.prod_blg_um
|| ' '
|| product.prod_stck_um,
product.prod_blg_um, quote_by_dst.qte_ln_brk_1_blg_uom_am,
quote_by_dst.qte_csup_avg_cst_am,
quote_by_dst.qte_csup_rev_gm_pct_am,
quote_by_dst.qte_csup_avg_cst_am, cs_ship_by_dst.bto_id,
cs_ship_by_dst.bto_ds_cac_cd,
cs_ship_by_dst.bto_ds_cac_cd
|| product.prod_id
|| cs_ship_by_dst.bto_id
FROM infowhse.quote_by_dst4 quote_by_dst,
infowhse.product,
infowhse.cs_ship_by_dst4 cs_ship_by_dst,
infowhse.department
WHERE (quote_by_dst.dpt_cd = department.dpt_cd)
AND (quote_by_dst.cus_dpt_id = cs_ship_by_dst.cus_dpt_id)
AND (product.prod_id = quote_by_dst.prod_id)
AND ( ( quote_by_dst.qte_ln_cond_cd = 'E'
OR quote_by_dst.qte_ln_cond_cd = 'C'
AND quote_by_dst.qte_hdr_stat_cd = 'A'
AND ((cs_ship_by_dst.bto_cust_type_cd) = '01')
AND cs_ship_by_dst.bto_ds_cac_ownr_ud = 'EHOC'
AND department.dpt_cd > '0.00'
)Explain plan
Plan
SELECT STATEMENT CHOOSECost: 911,832,256 Bytes: 433,941,639,459 Cardinality: 2,729,192,701
15 SORT UNIQUE Cost: 911,832,256 Bytes: 433,941,639,459 Cardinality: 2,729,192,701
14 NESTED LOOPS Cost: 68,705 Bytes: 433,941,639,459 Cardinality: 2,729,192,701
12 HASH JOIN Cost: 68,705 Bytes: 425,754,061,356 Cardinality: 2,729,192,701
1 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.DST_SEC_DST_SEC_DST_CD_IX Cost: 25 Bytes: 922,700 Cardinality: 184,540
11 HASH JOIN Cost: 16,179 Bytes: 1,199,209,082 Cardinality: 7,941,782
2 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.DST_SEC_DST_SEC_DST_CD_IX Cost: 25 Bytes: 922,700 Cardinality: 184,540
10 HASH JOIN Cost: 15,879 Bytes: 3,374,060 Cardinality: 23,110
8 HASH JOIN Cost: 15,200 Bytes: 2,981,190 Cardinality: 23,110
6 HASH JOIN Cost: 13,113 Bytes: 1,779,470 Cardinality: 23,110
3 TABLE ACCESS FULL INFOWHSE.CUSTOMER_SHIP Cost: 5,640 Bytes: 42,372 Cardinality: 1,177
5 PARTITION RANGE ALL Partition #: 11 Partitions accessed #1 - #12
4 TABLE ACCESS FULL INFOWHSE.QUOTE Cost: 7,328 Bytes: 38,826,590 Cardinality: 946,990 Partition #: 11 Partitions accessed #1 - #12
7 TABLE ACCESS FULL INFOWHSE.PRODUCT Cost: 1,542 Bytes: 9,246,640 Cardinality: 177,820
9 INDEX FAST FULL SCAN NON-UNIQUE INFOWHSE.CUST_SHIP_SLSDST_DTP_SICALL_IX Cost: 185 Bytes: 9,878,411 Cardinality: 581,083
13 INDEX UNIQUE SCAN UNIQUE INFOWHSE.DEPARTMENT_PK Bytes: 3 Cardinality: 1This might be more useful.
Query is still running.
There is heavy wait time for scattered file read.
Results from
SELECT * FROM V$SESSION_WAIT WHERE SID = 48;
SID SEQ# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAW WAIT_TIME SECONDS_IN_WAIT STATE
48 6865 db file scattered read file# 108 000000000000006C block# 1593370000000000026E69 blocks 32 0000000000000020 2 30 WAITED KNOWN TIME
SELECT * FROM V$SESSION_EVENT WHERE SID = 48;
SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT MAX_WAIT TIME_WAITED_MICRO
48 log file sync 1 0 0 0 0 563
48 db file sequential read 11 0 0 0 0 243
48 db file scattered read 6820 0 330 0 7 3296557
48 SQL*Net message to client 19 0 0 0 0 23
48 SQL*Net message from client 18 0 128 7 127 1281912 Sorry for long post. -
Physical queries generated with DISTINCT clause
Hi All,
We have a model with three dimension tables and a fact table. All the join conditions between dimension and fact tables are defined and dimension with level keys.
Apart from this, one of the dimension is used for applying the row level filter.
Oracle BI is generating physical queries with DISTINCT clause, which is impacting the performance of the query exeuction. Any tips in modification to business model to avoid the generation of DISTINCT clause would be appreciated.
Thanks,
Phanihi,
Open RPD-->Double click on Logical table source in BMM layer and go to content tab .you will have Select Distinct Values by default it was uncheck if that is checked uncheck that one....(this one is only to restrict from BMM layer)
thanks,
saichand.v -
Distinct clause ignores special characters
Hi all,
Assume I have following 2 addresses from Address Field.
BAHNSTRASSE
BAHNSTRAßE
when I query to DB on this fields to get distinct addresses, the DISTINCT clause considers it as a same address only.
same thing is happened with UNION also.
Is it a drawback of DISTINCT clause?
or am I missing some Code-Page setting of SQL Server?Ooh, don't use German_PhoneBook_CI_AI_WS, because it to do have a very special sorting algorithm
Better use an Acsend insensitive collation like SQL_Latin1_General_CP1_CI_AI
SELECT DISTINCT street
FROM
(SELECT 'BAHNSTRASSE' AS street
UNION ALL
SELECT 'BAHNSTRAßE') AS Sub
SELECT DISTINCT street
FROM
(SELECT 'BAHNSTRASSE' COLLATE SQL_Latin1_General_CP1_CI_AI AS street
UNION ALL
SELECT 'BAHNSTRAßE') AS Sub
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Tunning the Query with Distinct Clause
Hi All,
I have the below query that returns 28113657 records
select src_Wc_id, osp_id, src_osp_id
from osp_complements o1
where exists (select 1 from wc_crossref wc
where wc.src_wc_id = o1.SRC_WC_ID
and wc.state = 'CA')
This query executes within a second...
But when i include a DISTINCT clause in the select statement, it takes more time ... (more than 20 mins)
I am trying to get it tunned. Please advice me with your knowledge to get it done
Thanks for your time
Kannan.Retrieving distinct rows requires a sort of all returned rows. 20 - 3 = ~17 mins for sorting 28 mln rows looks too much. You need to tune your instance in order to speed up sort operation. The amount of memory dedicated to sorts is controlled by PGA_AGGREGATE_TARGET parameter. If it's set to 0 (not recommended) then SORT_AREA_SIZE is used. The process of PGA tuning is quite complex and described in PGA Memory Management chapter of Performance Tuning Guide.
There is a workaround which allows to bypass sort operation, but it requires proper index and proper access by that index. The idea is that rows rertrieved via index are automatically ordered by indexed columns. If that and only that columns (possibly - in the same order as in the index, I don't know) are selected using DISTINCT then sort is not actually performed. Rows are already sorted due to access via index.
Hope this will help you.
Regards,
Dima -
Suppress "Distinct" Clause from Answers Query
Hello All:
How can I suppress the "Distinct" clause that the BI Server issues to the Oracle Database?
For Ex:
I have a customer Table with FirstName and LastName as columns. If I Query FirstName and LastName in Answers, BI server sends a Query like this:
select distinct T8944.fname as c1,
T8944.lname as c2
from
CUSTOMER T8944
order by c1, c2
This will suppress customers having the same name even if their customer Id is different. I want their names included also.
I would appreciate your help.
Thanks
rkingmduAFAIK, there's no config setting or so to prevent this implicit grouping. What you can do though is to add the customer Id ot the report and make the column hidden (Column Format - Hide).
Hth,
Chris
Edited by: Christian Berg on Sep 25, 2008 4:39 PM:
Or what Matt said ;-) Should type faster... -
Passing null in ArrayList as part of EJB Method gives NullPointerException
Hi gurus,
I have many EJBS in my application. All are working fine but when I pass null as element of ArrayList (serializable object) and pass ArrayList object to SessionBean it gives me NullPointerException. I think as part of EJB Specification it allows the Serialized object as part of method call but I think Oracle9iAS 903 has this as an error.
e.g
ArrayList mylist = new ArrayList();
mylist.add("lar");
mylist.add("%");
mylist.add(new Long(0));
mylist.add("%");
mylist.add(new Long(0));
mylist.add("");
mylist.add("%");
mylist.add("Y");
mylist.add(null);
mylist.add(new Long(0));
Object obj= ictx.lookup("java:comp/env/sampleEJB");
SampleEJBHome home =(SampleEJBHome)PortableRemoteObject.narrow(obj,SampleEJBHome.class);
SampleEJB sampleEJB = home.create();
ArrayList retList =sampleEJB.test(mylist);
I think this is error in Oracle 903 IAS. Let me know If I am doing anything wrong here.
Thanks
RiteshI checked the bug status for you. It looks like one of our support analysts has tested the patch for the bug I mentioned to see if it resolves the similar problem you have and determined that it doesn't fix the problem you are facing. The bug you mention is still open and pending some further analysis by our bug fixing team.
The bug text isn't a 100% match what you have entered here in the forum, so it might be still worth your while to get the patch for bug 2753425 from support and test it in an isolated environment to see if it does resolve your problem. I'd recommend that you talk to your support analyst and discuss this with them.
cheers
-steve- -
GROUP BY and DISTINCT clause in single query
Hi All,
I have this query:
SELECT studyid,baseline_no,trans_date, min(trunc(compass_date)),drug_related_yn
FROM cp_bdr_trigger_tbl cbtt
WHERE NOT EXISTS (SELECT 1
FROM cp_patient_info_tbl
WHERE studyid = cbtt.studyid
AND baseline_no = cbtt.baseline_no)
AND studyid = '0431-020'
GROUP BY BASELINE_NO,STUDYID,DRUG_RELATED_YN;
The o/p of this query has around 20 rows with same studyid and distinct baseline_no.
Now I want to select the data all to be distinct by limiting it somehow by GROUP BY clause.
Is this possible?
I mean grouping should be done in such a way that it should return distinct values only...
The o/p of this query is input to other query for insertion in some table.
* there is a Unique index in the target table on studyid+basline_no combination so the combination has to be unique*
Thanks,
Aashish S.The GROUP BY is in a way an implied DISTINCT because it will return ONE record for each of the columns identified in the GROUP BY clause.
Either way your requirements aren't very clear. If you can please post the following we may be able to help:
1. Oracle version (e.g. 10.2.0.4)
2. CREATE / INSERT statements with sample data
3. Expected output
4. Use \ tags (surround #2 and #3 in these tags)
5. Explanation of logic in achieving #3.
Thanks! -
Enforce 'DISTINCT' clause in a db block....(solved)
Hi ,
Is it possible to set "distinct" in a db block....either in property palette or programmatically ..in PRE-QUERY , for example in Dev10g...????
Thanks ...
SimonYou can set distinct in the query or procedure if query data source type you are using is from clause or procedure. Don't know other ways
-
Query in jdeveloper using distinct clause
hello
I am a user of oracle10G jdeveloper using jclient/swing
in my product.
I had written a query in my default view object as
Select distinct(Name) from emp then i test it.
Then message get displayed Query is valid.
But when i bind this view object with my form ie with combobox using model property and finally run the form then it throw an error message .
Please do help me to sort out this problem .
thanksPlease post the error message and the exception stack.
My guess is that the error is: your VO's SQL statement did not include the primary key attribute (say Empno).
Thanks.
Sung -
Need distinct rows with using distinct clause
I have following requirement
Empid startdate end organisation
1 1-jan-2008 O1
2 2-jan-2008 31-jul-08 O1
3 2-jan-2008 31-jul-08 O1
4 2-jan-2008 31-jul-08 O2
5 2-jan-2008 31-jul-08 O2
6 2-jan-2008 31-jul-08 O2
7 2-jan-2008 31-jul-08 O3
8 2-jan-2008 31-jul-08 O3
My requirement is to get a sql query that report me something like this
Empid startdate end organisation
1 1-jan-2008 O1
4 2-jan-2008 31-jul-08 O2
7 2-jan-2008 31-jul-08 O3
That is any empid, startdate, end for a given organization (ie organization should be distinct)
regards
vikas
Edited by: user634784 on Jan 19, 2009 4:05 AMuser634784 wrote:
But is there any way to get the same outcome without using the subquery.In reality... No.
You can hide the fact that you have to generate a row_number for the records by using a view... ;)
SQL> ed
Wrote file afiedt.buf
1 create table t as select 1 as Empid, to_date('01-jan-2008','DD-MON-YYYY') as startdate, null as enddate, 'O1' as organisation from dual union all
2 select 2, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O1' from dual union all
3 select 3, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O1' from dual union all
4 select 4, to_date('5-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
5 select 5, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
6 select 6, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O2' from dual union all
7 select 7, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O3' from dual union all
8* select 8, to_date('2-jan-2008','DD-MON-YYYY'), to_date('31-jul-08','DD-MON-YYYY'), 'O3' from dual
9 /
Table created.
SQL> ed
Wrote file afiedt.buf
1 create view vw_x as
2* select empid, startdate, enddate, organisation, row_number() over (partition by organisation order by empid) rn from t
SQL> /
View created.
SQL> select * from vw_x where rn = 1;
EMPID STARTDATE ENDDATE OR RN
1 01-JAN-08 O1 1
4 05-JAN-08 31-JUL-08 O2 1
7 02-JAN-08 31-JUL-08 O3 1
SQL>
Maybe you are looking for
-
How to prevent creation of My * folders on Home drive
First a little background. Our enterprise (some 11,000+ computers) utilize Active Directory to manage user logons and credentials. Every user has a home drive mapped to one of our many servers as part of their Active Directory profile. As a matter of
-
Why Doesn't "Gift This Movie" Work For HD Movies?
So I'm making up the list of movies I'd like for Christmas, only to discover there's no way for someone else to gift me the HD iTunes movies I want. To reproduce this, go to an HD movie like Kill Bill or Star Trek, click on the little arrow next to "
-
I have an Rev A iMac G5. I recently took it in to Apple for repair. The logic board and capacitators were replaced. My internet connection has been extremely slow for the past few days. I use Airport to connect wirelessly. I've cleaned the cache, etc
-
Refresh button deleted by mistake
First, my thanks to Dave Sawyer for answering my help plea so quickly and directing me here to ask my question. My question is how do I get the refresh button (which I accidently deleted) back on Safari? Thank's in advance, Tessie2
-
Collaborate invite to alternate email
We're trying to get collaborative libraries working among our team, but are running into an invitation issue: Our Adobe IDs are not the same as our work emails and we don't have access to the emails used as Adobe IDs (that's the way IT set us up). Th