Finding Max Date
Hello,
I need to write a query that will look at two tables - one of which contains event information (pk = event_id), the other containing event_id's and broker_id's. One broker may have attended one or more events.
I need to find the most recent event that each broker attended. Also, it is possible that a broker attended more than one event on a given day, in which case I will need some logic that will prioritize which event to select if a broker attended more than one on the given max event date.
Any help with this sql would be greatly appreciated.
Thanks!
Christine
The business is currently determining the priority of
all event types. Once that is clear, I'll need to
incorporate that logic into my sql statement.
However, I'm not sure how to do that using this
logic:
ROW_NUMBER () OVER (PARTITION BY broker_id ORDER BY
event_date DESC)
I haven't used row number over and partitioning
before, so I'm not sure how it works. If, forSearch the Oracle documentation or this site for "Analytic Functions". Specifically:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions137.htm#sthref1981
instance, the business decides that event type
priority is something like: 5, 7, 1, 3, 11,
2......., how would I include that logic in the
statement above?
Would it be better to just add a priority column on
my event_type lookup table?
Thanks to all of you for your help with this!!Note how the row_number() value is assigned a value of 1 if the event_date is more recent. It has been assumed that you are storing timestamps as well, in the "event_date" column.
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select
26 er.broker_id, e.event_date, e.type, e.event_id,
27 row_number() over (partition by er.broker_id order by e.event_date desc) as seq
28 from
29 event_registration er,
30 event e,
31 contacts c
32 where er.event_id=e.event_id
33 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 15:00:00 3 31 1
1000155 01/19/2006 08:02:25 1 30 2
7 rows selected.
test@ORA10G>
test@ORA10G>That's due to the way the ORDER BY clause in the analytic function (in bold) has been defined. For every broker_id (partition by er.broker_id), it orders the records, most recent first (order by e.event_date desc), and hands out a "row number".
If you want to go ahead with Case (B) earlier, then you need to order by event_type ascending, so that the lowest event_type would have a "row_number()" values of 1, thusly:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select
26 er.broker_id, e.event_date, e.type, e.event_id,
27 row_number() over (partition by er.broker_id order by e.type) as seq
28 from
29 event_registration er,
30 event e,
31 contacts c
32 where er.event_id=e.event_id
33 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 08:02:25 1 30 1
1000155 01/19/2006 15:00:00 3 31 2
7 rows selected.
test@ORA10G>
test@ORA10G>Note how the more recent meeting has been relegated because it did not have a lower value of event_type.
Thereafter you just select the records with seq = 1.
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3 from dual ),
9 contacts as (
10 select 1000073 as broker_id from dual union all
11 select 1000127 from dual union all
12 select 1000140 from dual union all
13 select 1000144 from dual union all
14 select 1000154 from dual union all
15 select 1000155 from dual),
16 event_registration as (
17 select 1000073 as broker_id, 957 as event_id from dual union all
18 select 1000127, 97 from dual union all
19 select 1000140, 2142 from dual union all
20 select 1000144, 728 from dual union all
21 select 1000154, 363 from dual union all
22 select 1000155, 30 from dual union all
23 select 1000155, 31 from dual)
24 --
25 select broker_id,event_date,type,event_id
26 from (
27 select
28 er.broker_id, e.event_date, e.type, e.event_id,
29 row_number() over (partition by er.broker_id order by e.type) as seq
30 from
31 event_registration er,
32 event e,
33 contacts c
34 where er.event_id=e.event_id
35 and er.broker_id=c.broker_id
36 )
37 where seq = 1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 08:02:25 1 30
6 rows selected.
test@ORA10G>
test@ORA10G>You could use a "priority" column, with values like, say, 1, 3 and 5 for low, medium and high priorities, for each event.
In that case, your query could be:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 1 as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 5 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 5 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 3 from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 1 from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select
28 er.broker_id, e.event_date, e.type, e.event_id,
29 row_number() over (partition by er.broker_id order by e.priority) as seq
30 from
31 event_registration er,
32 event e,
33 contacts c
34 where er.event_id=e.event_id
35 and er.broker_id=c.broker_id;
BROKER_ID EVENT_DATE TYPE EVENT_ID SEQ
1000073 10/19/2005 09:10:23 3 957 1
1000127 03/07/2006 09:10:23 1 97 1
1000140 02/05/2008 10:34:56 1 2142 1
1000144 05/19/2005 17:29:11 1 728 1
1000154 05/12/2006 08:02:25 2 363 1
1000155 01/19/2006 19:00:00 3 32 1
1000155 01/19/2006 15:00:00 3 31 2
1000155 01/19/2006 08:02:25 1 30 3
8 rows selected.
test@ORA10G>
test@ORA10G>And hence:
test@ORA10G>
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 1 as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 3 from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 1 from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 5 from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 5 from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 3 from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 1 from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select broker_id,event_date,type,event_id
28 from (
29 select
30 er.broker_id, e.event_date, e.type, e.event_id,
31 row_number() over (partition by er.broker_id order by e.priority) as seq
32 from
33 event_registration er,
34 event e,
35 contacts c
36 where er.event_id=e.event_id
37 and er.broker_id=c.broker_id
38 )
39 where seq=1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 19:00:00 3 32
6 rows selected.
test@ORA10G>
test@ORA10G>
test@ORA10G>If you go for mnemonic values of priority like, say, "L", "M", "H" then you could try something like:
test@ORA10G>
test@ORA10G> with event as (
2 select 957 as event_id, to_date('10/19/2005 09:10:23','mm/dd/yyyy hh24:mi:ss') as event_date, 3 as type, 'H' as priority from dual union all
3 select 97, to_date('3/7/2006 09:10:23','mm/dd/yyyy hh24:mi:ss'), 1, 'M' from dual union all
4 select 2142, to_date('2/5/2008 10:34:56','mm/dd/yyyy hh24:mi:ss'), 1, 'M' from dual union all
5 select 728, to_date('5/19/2005 17:29:11','mm/dd/yyyy hh24:mi:ss'), 1, 'H' from dual union all
6 select 363, to_date('5/12/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 2, 'L' from dual union all
7 select 30, to_date('1/19/2006 08:02:25','mm/dd/yyyy hh24:mi:ss'), 1, 'L' from dual union all
8 select 31, to_date('1/19/2006 15:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 'M' from dual union all
9 select 32, to_date('1/19/2006 19:00:00','mm/dd/yyyy hh24:mi:ss'), 3, 'H' from dual),
10 contacts as (
11 select 1000073 as broker_id from dual union all
12 select 1000127 from dual union all
13 select 1000140 from dual union all
14 select 1000144 from dual union all
15 select 1000154 from dual union all
16 select 1000155 from dual),
17 event_registration as (
18 select 1000073 as broker_id, 957 as event_id from dual union all
19 select 1000127, 97 from dual union all
20 select 1000140, 2142 from dual union all
21 select 1000144, 728 from dual union all
22 select 1000154, 363 from dual union all
23 select 1000155, 30 from dual union all
24 select 1000155, 31 from dual union all
25 select 1000155, 32 from dual)
26 --
27 select broker_id,event_date,type,event_id
28 from (
29 select
30 er.broker_id, e.event_date, e.type, e.event_id,
31 row_number() over (partition by er.broker_id order by (case e.priority when 'L' then 1 when 'M' then 2 when 'H' then 3 end) desc) as seq
32 from
33 event_registration er,
34 event e,
35 contacts c
36 where er.event_id=e.event_id
37 and er.broker_id=c.broker_id
38 )
39 where seq=1;
BROKER_ID EVENT_DATE TYPE EVENT_ID
1000073 10/19/2005 09:10:23 3 957
1000127 03/07/2006 09:10:23 1 97
1000140 02/05/2008 10:34:56 1 2142
1000144 05/19/2005 17:29:11 1 728
1000154 05/12/2006 08:02:25 2 363
1000155 01/19/2006 19:00:00 3 32
6 rows selected.
test@ORA10G>
test@ORA10G>to achieve the same result.
HTH,
pratz
Similar Messages
-
Find MAX date for Person XYZ , and also MIN date for same Person?
List of dates in Column A , list of Persons in Column B. My problem is that I have In C1 the formula which part of it is =SUMPRODUCT(MAX((B4:B200=A2)*A4:A200))) to find the MIN date for the person specified in cell A2, but this formula returns an error. Please help
Many thanks
NB: I use Numbers for the iPhone
ans Icloude Numbers beta in the iMac 21.5Hi atapp,
Here is my solution to your problem. The footer cell A11 is where you type your search. You could easily change this to C1 if tha makes more sense to you. Colomn C is where the action is and it could be hidden. The formulas in the two footer rows are =MAX(C) and =MIN(C) so even though they are in Column B they are looking at Column C.
The formula in C2 is filled down.
Give it a try.
quinn -
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
I tried a SELECT from (....) as follows*
select * from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES)
This is woking perfectly. But when I tried to do max(*) i.e select max(*) from ......... gives error again.
Can some one suggest me a query to full fill my requirement please.
Thanks
Rupesh
www.orachat.comHi, Rupesh,
rupesh.sreenivas wrote:
Hi ALL,
I need to find max date from a union result. I tried to use bellow query,
select max(last_processed) from
(select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
Anything inside quotes (including double-quotes) is case-sensitive. Everything not in quotes is capitalized before compiling. So
last_processed is the same as
"LAST_PROCESSED", but different from
"last_processed".
Don't use double-quotes. -
Find the correct max date and then loop to find 3 consecutive unique no.'s
Hi, this relates to a similar query I posted however this is my problem in its entirety. here is the link: Keep Dense_Rank problem
This is what I need to do:
1) Select the max date in a month per unique Receiver_ID. NOTE: there are special cases such as Due_Date = 01-March-2011 in the sample data. When this occurs, the date with the greatest acc_payment_no must be chosen.
2) Each Receiver_ID has a corresponding payment_status and acc_payment_no. Payment_status is either 9 or 4.
3) I have a variable called v_incident_date
4) I am focused on the Due_Dates that are within 6 months of the v_incident_date ie where Due_Date Between add_months(v_cla_event.Incident_date, - 6) and v_incident_date5) This is the tricky part. Once I have identified the Due_Dates I am interested in and their corresponding payment_status's, I want to search for THREE CONSECUTIVE payment_Status = 9 and if this is the case return 'Y' else 'N'.
Here is the sample data:
CREATE TABLE acc_payment_test_a (Receiver_ID varchar2(50), Due_Date Date, acc_paymnet_no varchar2(50), payment_status varchar2(50));
CREATE TABLE acc_payment_test_a (Receiver_ID varchar2(50), Due_Date Date, acc_paymnet_no varchar2(50), payment_status varchar2(50));
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('03-MAR-2008 00.00','DD-MON-YYYY HH24:MI'),1083,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('05-MAR-2008 00.00','DD-MON-YYYY HH24:MI'),1084,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-APR-2008 00.00','DD-MON-YYYY HH24:MI'),2762,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAY-2008 00.00','DD-MON-YYYY HH24:MI'),8211,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-JUN-2008 00.00','DD-MON-YYYY HH24:MI'),20144,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUL-2008 00.00','DD-MON-YYYY HH24:MI'),36534,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-AUG-2008 00.00','DD-MON-YYYY HH24:MI'),56661,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-SEP-2008 00.00','DD-MON-YYYY HH24:MI'),78980,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-OCT-2008 00.00','DD-MON-YYYY HH24:MI'),107595,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-NOV-2008 00.00','DD-MON-YYYY HH24:MI'),192768,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-DEC-2008 00.00','DD-MON-YYYY HH24:MI'),223835,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-JAN-2009 00.00','DD-MON-YYYY HH24:MI'),281414,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-FEB-2009 00.00','DD-MON-YYYY HH24:MI'),322990,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-MAR-2009 00.00','DD-MON-YYYY HH24:MI'),364489,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-APR-2009 00.00','DD-MON-YYYY HH24:MI'),417224,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-MAY-2009 00.00','DD-MON-YYYY HH24:MI'),466501,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUN-2009 00.00','DD-MON-YYYY HH24:MI'),523088,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUL-2009 00.00','DD-MON-YYYY HH24:MI'),559526,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-AUG-2009 00.00','DD-MON-YYYY HH24:MI'),619977,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-SEP-2009 00.00','DD-MON-YYYY HH24:MI'),680457,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-OCT-2009 00.00','DD-MON-YYYY HH24:MI'),731996,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-NOV-2009 00.00','DD-MON-YYYY HH24:MI'),789924,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-DEC-2009 00.00','DD-MON-YYYY HH24:MI'),850743,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JAN-2010 00.00','DD-MON-YYYY HH24:MI'),918113,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-FEB-2010 00.00','DD-MON-YYYY HH24:MI'),982257,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAR-2010 00.00','DD-MON-YYYY HH24:MI'),1029219,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-APR-2010 00.00','DD-MON-YYYY HH24:MI'),1103165,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAY-2010 00.00','DD-MON-YYYY HH24:MI'),1173876,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUN-2010 00.00','DD-MON-YYYY HH24:MI'),1241791,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUL-2010 00.00','DD-MON-YYYY HH24:MI'),1316343,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('02-AUG-2010 00.00','DD-MON-YYYY HH24:MI'),1384261,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-SEP-2010 00.00','DD-MON-YYYY HH24:MI'),1467071,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-OCT-2010 00.00','DD-MON-YYYY HH24:MI'),1548259,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-NOV-2010 00.00','DD-MON-YYYY HH24:MI'),1626770,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('22-NOV-2010 00.00','DD-MON-YYYY HH24:MI'),1751476,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('03-JAN-2011 00.00','DD-MON-YYYY HH24:MI'),1824718,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-FEB-2011 00.00','DD-MON-YYYY HH24:MI'),1939968,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAR-2011 00.00','DD-MON-YYYY HH24:MI'),2130326,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAR-2011 00.00','DD-MON-YYYY HH24:MI'),2126550,9);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-MAR-2011 00.00','DD-MON-YYYY HH24:MI'),2033664,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-APR-2011 00.00','DD-MON-YYYY HH24:MI'),2151353,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('03-MAY-2011 00.00','DD-MON-YYYY HH24:MI'),2251549,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUN-2011 00.00','DD-MON-YYYY HH24:MI'),2384223,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-JUL-2011 00.00','DD-MON-YYYY HH24:MI'),2504840,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_paymnet_no, payment_status) VALUES (151823,to_date('01-AUG-2011 00.00','DD-MON-YYYY HH24:MI'),2615647,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_payment_no, payment_status) VALUES (151823,to_date('01-SEP-2011 00.00','DD-MON-YYYY HH24:MI'),2756098,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_payment_no, payment_status) VALUES (151823,to_date('05-SEP-2011 00.00','DD-MON-YYYY HH24:MI'),2789669,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_payment_no, payment_status) VALUES (151823,to_date('01-OCT-2011 00.00','DD-MON-YYYY HH24:MI'),2944532,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_payment_no, payment_status) VALUES (151823,to_date('01-NOV-2011 00.00','DD-MON-YYYY HH24:MI'),3056013,4);
INSERT INTO acc_payment_test_a(Receiver_ID, Due_Date, acc_payment_no, payment_status) VALUES (151824,to_date('01-DEC-2011 00.00','DD-MON-YYYY HH24:MI'),3230490,4);
select * from acc_payment_test_aBanner:
Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Edited by: 885178 on Jan 12, 2012 4:38 PM
I added the acc_payment_no as time_stamp is not reliableHere is some sample data with the results I want. Note that I am creating a package and using the variables so v_cla_case_no and v_cla_event.Incident_date so there is no need to join onto the cla_case_table
This is an example of the package and package body. Cla_case_no and name_id_no are from Cla_case and Incident_date is from cla_event.
create or replace
PACKAGE "FIND"
IS
v_cla_case cla_case%ROWTYPE;
v_cla_event cla_event%ROWTYPE;
v_score NUMBER(10);
PROCEDURE Find_Factors(p_claim_case_no in number);
END FIND;
create or replace
PACKAGE BODY "FIND" IS
PROCEDURE Find_Factors(p_claim_case_no in number) IS
BEGIN
x_trace ('Find_Factors') ;
x_trace ('Cla_Case') ;
select *
into v_cla_case
from cla_case
where cla_case_no = p_claim_case_no;
x_trace ('Cla_Event') ;
select *
into v_cla_event
from cla_event ce
where ce.cla_event_no = v_cla_case.cla_event_no;
--Here is an example of the code I use
x_trace ('Score') ;
Select score
into v_score
from rbn_itc
where newest = 'Y'
and customer_no = v_cla_case.name_id_no;
END Find_Factors;
END FIND;
--DROP TABLE Cla_case
CREATE TABLE Cla_case (Cla_case_no INT,Name_ID_no int, Incident_Date varchar2(50) );
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (2879,325309,'2008-06-28');
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (3706,227013,'2008-08-02');
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (3806,467693,'2008-08-11');
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (4346,221694,'2008-08-22');
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (4612,221694,'2008-08-29');
INSERT INTO Cla_case (Cla_case_no ,Name_ID_no , Incident_Date ) VALUES (4870,422711,'2008-09-16');
select * from Cla_case
--DROP TABLE Acc_Payments
CREATE TABLE Acc_Payments (Payment_Status INT,Receiver_ID int, Due_Date varchar2(50));
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,325309,'2008-04-29');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,325309,'2008-05-06');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,325309,'2008-06-02');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,325309,'2008-06-05');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,325309,'2008-07-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,325309,'2008-07-03');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,325309,'2008-07-28');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-05-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-06-02');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-07-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,227013,'2008-07-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-08-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-08-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-09-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-09-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,227013,'2008-10-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-06-07');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-07-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-07-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-08-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,467693,'2008-08-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-09-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-09-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-10-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-10-27');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-11-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-12-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2008-12-15');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2009-01-15');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,467693,'2009-02-16');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,221694,'2008-05-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-06-02');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-07-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-07-10');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-08-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,221694,'2008-08-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-09-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-09-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-10-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-10-27');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-11-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-11-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-12-01');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2008-12-27');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2009-01-02');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,221694,'2009-02-02');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-06-05');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,422711,'2008-06-12');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-07-07');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-07-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-08-11');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-08-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-09-09');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (4,422711,'2008-09-26');
INSERT INTO Acc_Payments (Payment_Status ,Receiver_ID , Due_Date) VALUES (9,422711,'2008-10-09');
Select * from Acc_Payments
--Drop Table Result
CREATE TABLE Result (Cla_case_no INT,Receiver_ID int, Name_ID_no int, Incident_Date varchar2(50), Desired_Missed varchar(25) );
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (2879,325309,325309,'2008-06-28','N');
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (3706,227013,227013,'2008-08-02','N');
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (3806,467693,467693,'2008-08-11','Y');
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (4346,221694,221694,'2008-08-22','Y');
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (4612,221694,221694,'2008-08-29','N');
INSERT INTO Result (Cla_case_no ,Receiver_ID , Name_ID_no , Incident_Date, Desired_Missed ) VALUES (4870,422711,422711,'2008-09-16','Y');
Select * from Result -
Finding difference between Max date and Min date from single date field
Dear Experts,
Here I am with a scenario where i didnt find any solution in SDN and in most threads it is unanswered.
I have 1 KF which is a date field. With reference to Serial no, I want to find out the Max and Min date from the same KF. I created 2 CKF where the same KF is used in both CKF to find the Min and Max dates,
Ex:
Serial No | Material | Actual Del date | Max | Min | Difference
0123 | 300012 | 01.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300013 | 07.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300018 | 15.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300014 | 30.01.2009 | 31.01.2009 | 01.01.2009 | 30
0124 | 300019 | 02.01.2009 | 10.01.2009 | 02.01.2009 | 8
0124 | 300012 | 06.01.2009 | 10.01.2009 | 02.01.2009 | 8
0124 | 300017 | 10.01.2009 | 10.01.2009 | 02.01.2009 | 8
This is the way how I want the output where now I am able to get the values right till Max and Min and not the difference. I even created the 3rd CKF the find the difference but it is not working.
How can I find the difference between the Max and Min dates?
Regards,
ChanHi
You have FM --DAYS_BETWEEN_TWO_DATES you can use this while Customer Exit.
Try to Have 2 RKF for Min Data and Max Date and create a formula/CKF on the same ..
Hope it helps -
How to find the max data transfer rate(disk speed) supported by mobo?
I plan on replacing my current HDD with a new and bigger HDD.
For this I need to know the max data transfer rate(disk speed) that my mobo will support. However, dmidecode is not telling me that. Am I missing something?
Here's dmidecode:
# dmidecode 2.11
SMBIOS 2.5 present.
80 structures occupying 2858 bytes.
Table at 0x000F0450.
Handle 0xDA00, DMI type 218, 101 bytes
OEM-specific Type
Header and Data:
DA 65 00 DA B2 00 17 4B 0E 38 00 00 80 00 80 01
00 02 80 02 80 01 00 00 A0 00 A0 01 00 58 00 58
00 01 00 59 00 59 00 01 00 75 01 75 01 01 00 76
01 76 01 01 00 05 80 05 80 01 00 D1 01 19 00 01
00 15 02 19 00 02 00 1B 00 19 00 03 00 19 00 19
00 00 00 4A 02 4A 02 01 00 0C 80 0C 80 01 00 FF
FF 00 00 00 00
Handle 0xDA01, DMI type 218, 35 bytes
OEM-specific Type
Header and Data:
DA 23 01 DA B2 00 17 4B 0E 38 00 10 F5 10 F5 00
00 11 F5 11 F5 00 00 12 F5 12 F5 00 00 FF FF 00
00 00 00
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Dell Inc.
Version: A17
Release Date: 04/06/2010
Address: 0xF0000
Runtime Size: 64 kB
ROM Size: 4096 kB
Characteristics:
PCI is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
Selectable boot is supported
EDD is supported
Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 17.0
Handle 0x0100, DMI type 1, 27 bytes
System Information
Manufacturer: Dell Inc.
Product Name: OptiPlex 755
Version: Not Specified
UUID: 44454C4C-5900-1050-8033-C4C04F434731
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified
Handle 0x0200, DMI type 2, 8 bytes
Base Board Information
Manufacturer: Dell Inc.
Product Name: 0PU052
Version:
Handle 0x0300, DMI type 3, 13 bytes
Chassis Information
Manufacturer: Dell Inc.
Type: Space-saving
Lock: Not Present
Version: Not Specified
Asset Tag:
Boot-up State: Safe
Power Supply State: Safe
Thermal State: Safe
Security Status: None
Handle 0x0400, DMI type 4, 40 bytes
Processor Information
Socket Designation: CPU
Type: Central Processor
Family: Xeon
Manufacturer: Intel
ID: 76 06 01 00 FF FB EB BF
Signature: Type 0, Family 6, Model 23, Stepping 6
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
DS (Debug store)
ACPI (ACPI supported)
MMX (MMX technology supported)
FXSR (FXSAVE and FXSTOR instructions supported)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
SS (Self-snoop)
HTT (Multi-threading)
TM (Thermal monitor supported)
PBE (Pending break enabled)
Version: Not Specified
Voltage: 0.0 V
External Clock: 1333 MHz
Max Speed: 5200 MHz
Current Speed: 2666 MHz
Status: Populated, Enabled
Upgrade: Socket LGA775
L1 Cache Handle: 0x0700
L2 Cache Handle: 0x0701
L3 Cache Handle: Not Provided
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Core Count: 2
Core Enabled: 2
Thread Count: 2
Characteristics:
64-bit capable
Handle 0x0700, DMI type 7, 19 bytes
Cache Information
Socket Designation: Not Specified
Configuration: Enabled, Not Socketed, Level 1
Operational Mode: Write Back
Location: Internal
Installed Size: 32 kB
Maximum Size: 32 kB
Supported SRAM Types:
Other
Installed SRAM Type: Other
Speed: Unknown
Error Correction Type: None
System Type: Data
Associativity: 8-way Set-associative
Handle 0x0701, DMI type 7, 19 bytes
Cache Information
Socket Designation: Not Specified
Configuration: Enabled, Not Socketed, Level 2
Operational Mode: Varies With Memory Address
Location: Internal
Installed Size: 6144 kB
Maximum Size: 6144 kB
Supported SRAM Types:
Other
Installed SRAM Type: Other
Speed: Unknown
Error Correction Type: Single-bit ECC
System Type: Unified
Associativity: <OUT OF SPEC>
Handle 0x0800, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: PARALLEL
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: DB-25 female
Port Type: Parallel Port PS/2
Handle 0x0801, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: SERIAL1
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: DB-9 male
Port Type: Serial Port 16550A Compatible
Handle 0x0802, DMI type 126, 9 bytes
Inactive
Handle 0x0803, DMI type 126, 9 bytes
Inactive
Handle 0x0804, DMI type 126, 9 bytes
Inactive
Handle 0x0805, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB1
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0806, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB2
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0807, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB3
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0808, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB4
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x0809, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB5
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x080A, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB6
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x080B, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB7
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x080C, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: USB8
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x080D, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: ENET
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: RJ-45
Port Type: Network Port
Handle 0x080E, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: MIC
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Mini Jack (headphones)
Port Type: Audio Port
Handle 0x080F, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: LINE-OUT
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Mini Jack (headphones)
Port Type: Audio Port
Handle 0x0810, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: LINE-IN
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Mini Jack (headphones)
Port Type: Audio Port
Handle 0x0811, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: HP-OUT
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: Mini Jack (headphones)
Port Type: Audio Port
Handle 0x0812, DMI type 8, 9 bytes
Port Connector Information
Internal Reference Designator: MONITOR
Internal Connector Type: None
External Reference Designator: Not Specified
External Connector Type: DB-15 female
Port Type: Video Port
Handle 0x090A, DMI type 9, 13 bytes
System Slot Information
Designation: SLOT1
Type: x1 Proprietary
Current Usage: In Use
Length: Long
Characteristics:
PME signal is supported
Handle 0x0901, DMI type 126, 13 bytes
Inactive
Handle 0x0902, DMI type 9, 13 bytes
System Slot Information
Designation: SLOT2
Type: 32-bit PCI
Current Usage: Available
Length: Long
ID: 2
Characteristics:
5.0 V is provided
3.3 V is provided
PME signal is supported
Handle 0x0903, DMI type 126, 13 bytes
Inactive
Handle 0x0904, DMI type 126, 13 bytes
Inactive
Handle 0x0905, DMI type 126, 13 bytes
Inactive
Handle 0x0906, DMI type 126, 13 bytes
Inactive
Handle 0x0907, DMI type 126, 13 bytes
Inactive
Handle 0x0908, DMI type 126, 13 bytes
Inactive
Handle 0x0A00, DMI type 10, 6 bytes
On Board Device Information
Type: Video
Status: Disabled
Description: Intel Graphics Media Accelerator 950
Handle 0x0A02, DMI type 10, 6 bytes
On Board Device Information
Type: Ethernet
Status: Enabled
Description: Intel Gigabit Ethernet Controller
Handle 0x0A03, DMI type 10, 6 bytes
On Board Device Information
Type: Sound
Status: Enabled
Description: Intel(R) High Definition Audio Controller
Handle 0x0B00, DMI type 11, 5 bytes
OEM Strings
String 1: www.dell.com
Handle 0x0D00, DMI type 13, 22 bytes
BIOS Language Information
Language Description Format: Long
Installable Languages: 1
en|US|iso8859-1
Currently Installed Language: en|US|iso8859-1
Handle 0x0F00, DMI type 15, 29 bytes
System Event Log
Area Length: 2049 bytes
Header Start Offset: 0x0000
Header Length: 16 bytes
Data Start Offset: 0x0010
Access Method: Memory-mapped physical 32-bit address
Access Address: 0xFFF01000
Status: Valid, Not Full
Change Token: 0x00000018
Header Format: Type 1
Supported Log Type Descriptors: 3
Descriptor 1: POST error
Data Format 1: POST results bitmap
Descriptor 2: System limit exceeded
Data Format 2: System management
Descriptor 3: Log area reset/cleared
Data Format 3: None
Handle 0x1000, DMI type 16, 15 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 8 GB
Error Information Handle: Not Provided
Number Of Devices: 4
Handle 0x1100, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: DIMM_1
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Manufacturer: AD00000000000000
Handle 0x1101, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: DIMM_3
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Handle 0x1102, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: DIMM_2
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Handle 0x1103, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: DIMM_4
Bank Locator: Not Specified
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz
Handle 0x1300, DMI type 19, 15 bytes
Memory Array Mapped Address
Starting Address: 0x00000000000
Ending Address: 0x000FDFFFFFF
Range Size: 4064 MB
Physical Array Handle: 0x1000
Partition Width: 1
Handle 0x1400, DMI type 20, 19 bytes
Memory Device Mapped Address
Starting Address: 0x00000000000
Ending Address: 0x0007FFFFFFF
Range Size: 2 GB
Physical Device Handle: 0x1100
Memory Array Mapped Address Handle: 0x1300
Partition Row Position: 1
Interleave Position: 1
Interleaved Data Depth: 1
Handle 0x1401, DMI type 20, 19 bytes
Memory Device Mapped Address
Starting Address: 0x00080000000
Ending Address: 0x000FDFFFFFF
Range Size: 2016 MB
Physical Device Handle: 0x1101
Memory Array Mapped Address Handle: 0x1300
Partition Row Position: 1
Interleave Position: 1
Interleaved Data Depth: 1
Handle 0x1402, DMI type 20, 19 bytes
Memory Device Mapped Address
Starting Address: 0x00000000000
Ending Address: 0x0007FFFFFFF
Range Size: 2 GB
Physical Device Handle: 0x1102
Memory Array Mapped Address Handle: 0x1300
Partition Row Position: 1
Interleave Position: 2
Interleaved Data Depth: 1
Handle 0x1403, DMI type 20, 19 bytes
Memory Device Mapped Address
Starting Address: 0x00080000000
Ending Address: 0x000FDFFFFFF
Range Size: 2016 MB
Physical Device Handle: 0x1103
Memory Array Mapped Address Handle: 0x1300
Partition Row Position: 1
Interleave Position: 2
Interleaved Data Depth: 1
Handle 0x1410, DMI type 126, 19 bytes
Inactive
Handle 0x1800, DMI type 24, 5 bytes
Hardware Security
Power-On Password Status: Enabled
Keyboard Password Status: Not Implemented
Administrator Password Status: Enabled
Front Panel Reset Status: Not Implemented
Handle 0x1900, DMI type 25, 9 bytes
System Power Controls
Next Scheduled Power-on: *-* 00:00:00
Handle 0x1B10, DMI type 27, 12 bytes
Cooling Device
Type: Fan
Status: OK
OEM-specific Information: 0x0000DD00
Handle 0x1B11, DMI type 27, 12 bytes
Cooling Device
Type: Fan
Status: OK
OEM-specific Information: 0x0000DD01
Handle 0x1B12, DMI type 126, 12 bytes
Inactive
Handle 0x1B13, DMI type 126, 12 bytes
Inactive
Handle 0x1B14, DMI type 126, 12 bytes
Inactive
Handle 0x2000, DMI type 32, 11 bytes
System Boot Information
Status: No errors detected
Handle 0x8100, DMI type 129, 8 bytes
OEM-specific Type
Header and Data:
81 08 00 81 01 01 02 01
Strings:
Intel_ASF
Intel_ASF_001
Handle 0x8200, DMI type 130, 20 bytes
OEM-specific Type
Header and Data:
82 14 00 82 24 41 4D 54 01 01 00 00 01 A5 0B 02
00 00 00 00
Handle 0x8300, DMI type 131, 64 bytes
OEM-specific Type
Header and Data:
83 40 00 83 14 00 00 00 00 00 C0 29 05 00 00 00
F8 00 4E 24 00 00 00 00 0D 00 00 00 02 00 03 00
19 04 14 00 01 00 01 02 C8 00 BD 10 00 00 00 00
00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00
Handle 0x8800, DMI type 136, 6 bytes
OEM-specific Type
Header and Data:
88 06 00 88 5A 5A
Handle 0xD000, DMI type 208, 10 bytes
OEM-specific Type
Header and Data:
D0 0A 00 D0 01 03 FE 00 11 02
Handle 0xD100, DMI type 209, 12 bytes
OEM-specific Type
Header and Data:
D1 0C 00 D1 78 03 07 03 04 0F 80 05
Handle 0xD200, DMI type 210, 12 bytes
OEM-specific Type
Header and Data:
D2 0C 00 D2 F8 03 04 03 06 80 04 05
Handle 0xD201, DMI type 126, 12 bytes
Inactive
Handle 0xD400, DMI type 212, 242 bytes
OEM-specific Type
Header and Data:
D4 F2 00 D4 70 00 71 00 00 10 2D 2E 42 00 11 FE
01 43 00 11 FE 00 0F 00 25 FC 00 10 00 25 FC 01
11 00 25 FC 02 12 00 25 FC 03 00 00 25 F3 00 00
00 25 F3 04 00 00 25 F3 08 00 00 25 F3 0C 07 00
23 8F 00 08 00 23 F3 00 09 00 23 F3 04 0A 00 23
F3 08 0B 00 23 8F 10 0C 00 23 8F 20 0E 00 23 8F
30 0D 00 23 8C 40 A6 00 23 8C 41 A7 00 23 8C 42
05 01 22 FD 02 06 01 22 FD 00 8C 00 22 FE 00 8D
00 22 FE 01 9B 00 25 3F 40 9C 00 25 3F 00 09 01
25 3F 80 A1 00 26 F3 00 A2 00 26 F3 08 A3 00 26
F3 04 9F 00 26 FD 02 A0 00 26 FD 00 9D 00 11 FB
04 9E 00 11 FB 00 54 01 23 7F 00 55 01 23 7F 80
5C 00 78 BF 40 5D 00 78 BF 00 04 80 78 F5 0A 01
A0 78 F5 00 93 00 7B 7F 80 94 00 7B 7F 00 8A 00
37 DF 20 8B 00 37 DF 00 03 C0 67 00 05 FF FF 00
00 00
Handle 0xD401, DMI type 212, 172 bytes
OEM-specific Type
Header and Data:
D4 AC 01 D4 70 00 71 00 03 40 59 6D 2D 00 59 FC
02 2E 00 59 FC 00 6E 00 59 FC 01 E0 01 59 FC 03
28 00 59 3F 00 29 00 59 3F 40 2A 00 59 3F 80 2B
00 5A 00 00 2C 00 5B 00 00 55 00 59 F3 00 6D 00
59 F3 04 8E 00 59 F3 08 8F 00 59 F3 00 00 00 55
FB 04 00 00 55 FB 00 23 00 55 7F 00 22 00 55 7F
80 F5 00 58 BF 40 F6 00 58 BF 00 EB 00 55 FE 00
EA 00 55 FE 01 40 01 54 EF 00 41 01 54 EF 10 ED
00 54 F7 00 F0 00 54 F7 08 4A 01 53 DF 00 4B 01
53 DF 20 4C 01 53 7F 00 4D 01 53 7F 80 68 01 56
BF 00 69 01 56 BF 40 FF FF 00 00 00
Handle 0xD402, DMI type 212, 152 bytes
OEM-specific Type
Header and Data:
D4 98 02 D4 70 00 71 00 00 10 2D 2E 2D 01 21 FE
01 2E 01 21 FE 00 97 00 22 FB 00 98 00 22 FB 04
90 00 11 CF 00 91 00 11 CF 20 92 00 11 CF 10 E2
00 27 7F 00 E3 00 27 7F 80 E4 00 27 BF 00 E5 00
27 BF 40 D1 00 22 7F 80 D2 00 22 7F 00 45 01 22
BF 40 44 01 22 BF 00 36 01 21 F1 06 37 01 21 F1
02 38 01 21 F1 00 39 01 21 F1 04 2B 01 11 7F 80
2C 01 11 7F 00 4E 01 65 CF 00 4F 01 65 CF 10 D4
01 65 F3 00 D5 01 65 F3 04 D2 01 65 FC 00 D3 01
65 FC 01 FF FF 00 00 00
Handle 0xD403, DMI type 212, 157 bytes
OEM-specific Type
Header and Data:
D4 9D 03 D4 70 00 71 00 03 40 59 6D 17 01 52 FE
00 18 01 52 FE 01 19 01 52 FB 00 1A 01 52 FB 04
1B 01 52 FD 00 1C 01 52 FD 02 1D 01 52 F7 00 1E
01 52 F7 08 1F 01 52 EF 00 20 01 52 EF 10 21 01
52 BF 00 22 01 52 BF 40 87 00 59 DF 20 88 00 59
DF 00 E8 01 66 FD 00 E9 01 66 FD 02 02 02 53 BF
00 03 02 53 BF 40 04 02 53 EF 00 05 02 53 EF 10
06 02 66 DF 00 07 02 66 DF 20 08 02 66 EF 00 09
02 66 EF 10 17 02 66 F7 00 18 02 66 F7 08 44 02
52 BF 40 45 02 52 BF 00 FF FF 00 00 00
Handle 0xD800, DMI type 126, 9 bytes
Inactive
Handle 0xDD00, DMI type 221, 19 bytes
OEM-specific Type
Header and Data:
DD 13 00 DD 00 01 00 00 00 10 F5 00 00 00 00 00
00 00 00
Handle 0xDD01, DMI type 221, 19 bytes
OEM-specific Type
Header and Data:
DD 13 01 DD 00 01 00 00 00 11 F5 00 00 00 00 00
00 00 00
Handle 0xDD02, DMI type 221, 19 bytes
OEM-specific Type
Header and Data:
DD 13 02 DD 00 01 00 00 00 12 F5 00 00 00 00 00
00 00 00
Handle 0xDE00, DMI type 222, 16 bytes
OEM-specific Type
Header and Data:
DE 10 00 DE C1 0B 00 00 10 05 19 21 01 00 00 01
Handle 0x7F00, DMI type 127, 4 bytes
End Of Table
Hdparm also does not tell me the max data transfer rate (disk speed) of my current drive although this link : www.wdc.com/en/library/sata/2879-001146.pdf says that it is 3.0Gb/s
and here's hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: WDC WD800JD-75JNC0
Firmware Revision: 06.01C06
Standards:
Supported: 6 5 4
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
CHS current addressable sectors: 16514064
LBA user addressable sectors: 156250000
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 76293 MBytes
device size with M = 1000*1000: 80000 MBytes (80 GB)
cache/buffer size = 8192 KBytes
Capabilities:
LBA, IORDY(can be disabled)
Standby timer values: spec'd by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 8
Recommended acoustic management value: 128, current value: 254
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* DOWNLOAD_MICROCODE
SET_MAX security extension
Automatic Acoustic Management feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* SMART error logging
* SMART self-test
* Gen1 signaling speed (1.5Gb/s)
* Host-initiated interface power management
* SMART Command Transport (SCT) feature set
* SCT Long Sector Access (AC1)
* SCT LBA Segment Access (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
Security:
Master password revision code = 65534
supported
not enabled
not locked
frozen
not expired: security count
not supported: enhanced erase
Checksum: correct
Last edited by Inxsible (2011-03-27 04:40:49)I just checked my BIOS and my current setting is set at IDE although it also mentions that the default should be AHCI. Currently I have a dual boot of Windows 7 (need it for Tax software) and Arch
So I guess, when I get the new HDD, I will first set it to AHCI and then install the OSes on it. See if NCQ helps any, and if not I will turn it back and re-install (if I have to). I am planning to have Windows only in virtualbox in the new drive.
Anyhoo, while I was in the BIOS I found two things which I had questions about :
1) Under Onboard Devices --> Integrated NIC , my setting is currently set at "On w/PXE" and it says the default should be just "On". Would it be ok to change it back to On since its a single machine and its not booting an OS on any server. I just don't want to have to re-install anything now since I will be doing that in the new HDD.
2) How would I know whether my BIOS would support a 64 bit OS in Virtualbox? I checked some setting under Virtualization, but they weren't very clear.
I will edit this post and let you know exactly what settings were present under the Virtualization sub-section. -
How to get max date in variable using dynamic query
Hi,
the following code gets all dates from sourcetable i want only max date , so i thought max function can be added and it will work
but still i have to create a table for one value(scalar) can get it in any other effeciant way.
declare
TYPE date_string IS TABLE OF VARCHAR(1000);
date_obj date_string;
BEGIN
EXECUTE IMMEDIATE 'SELECT to_char('''||day1||'-'||month1||'-'||year1||''') FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;
FOR indx IN date_obj.FIRST..date_obj.LAST loop
dbms_output.put_line(
date_obj(indx));
END loop;
DBMS_OUTPUT.PUT_LINE('Sample output');
END;
yours sincerely944768 wrote:
the following code gets all dates from sourcetableNo it doesn't. What is the datatype of day1, month1 and year1? They cannot be DATE datatypes otherwise your TO_CHAR would fail with all that concatenation going on. And your TO_CHAR is returning a VARCHAR2 datatype... so you cannot say that it is getting all dates... because there are no DATE datatypes returned. It's getting a lot of strings, but certainly not DATE's.
i want only max date , so i thought max function can be added and it will work You can use the MAX function on a DATE datatype, but not on strings (at least not in the way you intend it to work).
Converting it to a DATE before doing the MAX will allow you to get the maximum date (assuming the date format is correct)
EXECUTE IMMEDIATE 'SELECT max(to_date(to_char('''||day1||'-'||month1||'-'||year1||'''),''DD-MM-YYYY'')) FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;Then you will find have the other issues...
a) you are then going to be fetching your DATEs in to a collection of VARCHAR strings. (Not even VARCHAR2, very poor). This should be DATE datatype
b) you are bulk collecting into a collection, when you are using MAX which will return a single value in your example
And you really should address the design issues:
c) why are day, month and year, not being stored in the database as a single DATE datatype in the first place
d) why does your code not know the name of the table it's querying requiring the use of very poor dynamic SQL techniques.
e) why are you loading data in a collection in expensive PGA memory... what can't you do in SQL that requires you to collect the data into memory first? -
How to find max based on 2 columns.
Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
Column A represents date and column B represent time.
How would I find max value of column A and with results for A find Max for B.
example
A - - - - - - - - - -B
101010 - - - - - 202020
101011 - - - - - 202021
101012 - - - - - 202021
101010 - - - - - 202022
101012 - - - - - 202020
What I looking for is
A - - - - - - - - - - B
101012 - - - - - 202021
ThanksYou can try one of the following...
sql> select * from temp;
A B
101010 202020
101011 202021
101012 202021
101010 202022
101012 202020
1 select a,b from (
2 select a,
3 b,
4 rank () over (order by a desc, b desc) rnk
5 from temp
6* ) where rnk = 1
sql> /
A B
101012 202021
1 select a,b from (
2 select a,b from temp
3 order by a desc, b desc
4* ) where rownum = 1
sql> /
A B
101012 202021Please try to provide create table statements and insert data scripts instead of "select * from table".
It helps creating your case easier. -
Hi!
There are different records in PSA.
When I load to DSO I need only max value for key figure.
For example, data in PSA:
Char| KF
1| 2
1| 5
1| 3
2| 1
If I use Overwrite then result is:
1| 3
2| 1
If I use Sum then result is:
1| 10
2| 1
But I need followed reult:
1| 5
2| 1
How can I find max value for KF without using FM or Programs?Hi,
You can do this in a Start routine.
Sort the source package and copy the records with the max value to another internal table which has the same structure as your source package.
In the end of the routine, over write records in source package with the records in the internal table.
THis will help.
- Jaimin -
SQL Help getting Max() date....
Hi gurus, Here is my situation:
Here is the sample data:
Policy_Id Policy-Exp_Dt COl_1
123_____10/30/2008 __ 333
123_____ 09/25/2008___445
123_____ 08/30/2008___443
Here i have to get the Policy-Exp_Dt from the second row; In other words for all rows which have a similar Policy_Id i should first find out the max(Policy-Exp_Dt) and get the next smallest available date to that.
I have tried using
select Policy_Id, COl_1, Policy_Exp_Dt from
table_1
where Policy-Exp_Dt = (select max(Policy-Exp_Dt)-1 from
table_1 a
where a.policy_id = table_1.policy_id)
but here i am getting the value = 10/30/2008 - 1 which is 10/29/2008 but i need the value 9/25/2008 which is the next available date less than the max() date.
Please Advise.
Edited by: user521009 on Jan 9, 2009 1:56 PMI thought to use lag - maybe not as appropriate a ranking functions.
Also we have a case where there is only One record for a policy - exclude this I guess!
drop table Max_but_One;
create table Max_but_One
Policy_Id integer not null,
Policy_Expires date not null,
Policy_Note varchar2(20) not null
-- Standard data
insert into Max_but_One values (123, to_date('30-08-2008','dd-mm-yyyy'), 'First note');
insert into Max_but_One values (123, to_date('25-09-2008','dd-mm-yyyy'), 'Second note');
insert into Max_but_One values (123, to_date('30-10-2008','dd-mm-yyyy'), 'Third note');
-- Standard data again for double check
insert into Max_but_One values (223, to_date('01-11-2008','dd-mm-yyyy'), 'First note');
insert into Max_but_One values (223, to_date('02-11-2008','dd-mm-yyyy'), 'Second note');
-- Only one record for a policy!
insert into Max_but_One values (323, to_date('01-12-2008','dd-mm-yyyy'), 'First note');
-- Two or more records for a policy both having the same date which is prior to the max
insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'First note');
insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'Second note');
insert into Max_but_One values (423, to_date('11-12-2008','dd-mm-yyyy'), 'Third note');
break on Policy_ID
select Policy_Id, Policy_Expires, Policy_Note
from Max_but_One
order by Policy_Id, Policy_Expires
POLICY_ID POLICY_EX POLICY_NOTE
123 30-AUG-08 First note
25-SEP-08 Second note
30-OCT-08 Third note
223 01-NOV-08 First note
02-NOV-08 Second note
323 01-DEC-08 First note
423 10-DEC-08 First note
10-DEC-08 Second note
11-DEC-08 Third note
-- Max Policy_Expires
select t.*
from (select Policy_Id, Policy_Expires, Policy_Note
,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
from Max_but_One
) t
where t.Policy_Expires = t.Max_Policy_Expires
POLICY_ID POLICY_EX POLICY_NOTE MAX_POLIC
123 30-OCT-08 Third note 30-OCT-08
223 02-NOV-08 Second note 02-NOV-08
323 01-DEC-08 First note 01-DEC-08
423 11-DEC-08 Third note 11-DEC-08
-- Using LAG
select t.Policy_Id
,t.Prior_Policy_Expires as Policy_Expires
,t.Prior_Policy_Note as Policy_Note
from (select Policy_Id, Policy_Expires, Policy_Note
,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
,lag(Policy_Note) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
from Max_but_One
) t
where t.Policy_Expires = t.Max_Policy_Expires
POLICY_ID POLICY_EX POLICY_NOTE
123 25-SEP-08 Second note
223 01-NOV-08 First note
323
423 10-DEC-08 Second note
-- To exclude the single record policy then add and t.Prior_Policy_Expires is not null
select t.Policy_Id
,t.Prior_Policy_Expires as Policy_Expires
,t.Prior_Policy_Note as Policy_Note
from (select Policy_Id, Policy_Expires, Policy_Note
,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
,lag(Policy_Note) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
from Max_but_One
) t
where t.Policy_Expires = t.Max_Policy_Expires
and t.Prior_Policy_Expires is not null
POLICY_ID POLICY_EX POLICY_NOTE
123 25-SEP-08 Second note
223 01-NOV-08 First note
423 10-DEC-08 Second note
-- 423 is randomly picked here - could equally have got {423, 10-DEC-08, First note} -
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
Can not find master data in the cube
ItemNo is an navigation attribute of 0Material. We are using 0material in a cube. When I display the cube data include ItemNo, I don't find the data I am looking for. For example:
In 0Material:
0Material ItemNo Description
AAA 001 Test
BBB 002 Test
In the cube I expect to see:
0Material ItemNo On Hand Qty
AAA 001 1000
BBB 002 2000
Instead I saw:
0Material ItemNo On Hand Qty
AAA 1000
BBB 2000
0Material got refreshed after cube data got loaded. Is that why I don't find the refreshed Master data?
Thank you!Hi,
When you laod the cube, the Values for Master are automatically get created in the master data (If they are not present earlier and with "Data Update Type in the Data Tragets" setting in InfoPackage).
Now when you are loading your cube with 0Material and Item Number, the values for Item Number seems blank. Thats the reason why you are not able to see the Item Number in Cube though it is present in Master. Because now these are two different keys, one with Item Number value and other without Item Number value.
Regards,
Yogesh. -
Can't find my data from Time Machine network backup
Migration assistant shows inconsistent sizes for applications, computer settings and other files/folders, about 30GB when I had 270 GB only in pictures.
I did a clean Mavericks install.
How do I find my data from the TimeMachine network backup?
The size of the TimeMachine backup is consistent with what I had before ( >300 GB)...so how do I recover it?.
I'm using a new user account name in the clean installation.
ThanksRead a few threads about this being a problem with account access, so I renamed the account in my new installation to the account name used to create the backup and found the old accounts....now when trying to proceed it told me there was a conflict with the account name and i had to use a different one!!.
Apple has stopped to be simple...
So how are we suppose to use the migration assistant if either way there is a problem? ( using same or different account name )... -
Can V find Master data datasource by having Transaction data datasource?
Hello All
I have a datasource in r/3 side by this can v find Master data datasource?
The Transaction datasource is 2lis_02_scl?
how to find Master datasource for this?
Many Thanks
balajiAHP hello
Thanks for info given
Can v view same for customized datasources also?
is it possible?
so for datasource 2lis_11_vaitm,if v click on "Infosource Overview" v can view all the Infosource name,by this v can find our Master Datasource.?
so for ex.,I can c infosource 0CUST_GRP1,so this is the datasource for Master data from r/3 side?
Is it correct?
Many Thanks
balaji -
HT1414 how can i find the dates of the latest backup for iphone and ipad
i cannot seem to find the dates of last backup for my iphone or ipad..
what buttons will lead me to the answeriTunes or iCloud?
iTunes - in preferences > devices
iCloud - from each device Settings > iCloud > Storage & Backup. The date last backed up will be below the Backup Now button.
Maybe you are looking for
-
How to use jack connection kit?
Im trying to get my external soundcard working. first of i start ffado-mixer. it recognize my soundcard and everything. I then type sudo jackd -d firewire in the terminal and get this output : JACK compiled with System V SHM support. loading driver .
-
i had brought c3-01 i connected to my home router its coming as connection successful later when go for browsing its loading and later coming as link is not available pls help me friends what should i do for this?
-
I brought Adobe Acrobat 8 and it has been working fine , but I brought a new computer windows 8 and i cannot download acrobat 8 again
-
Excel Throws an error for large data dumps
Hi, I have a report in which displays 10,00,000 records , for that i created an agent and run the report the data is loaded into excel when we open the excel it is throwing an error I so mimimum i need to display 5,00,000 records Thanks,
-
I am new to action script, can any when tell me how to retrieve request url in AS2.0