How to achieve this using an analytic function - please help
version 10g.This code works very well with my requirement. I'm tyring learn analytical functions and implement than in the query below. I tried to use row_number,
but I could nt achieve the desired results. Please give me some ideas.
SELECT c.tax_idntfctn_nmbr irs_number, c.legal_name irs_name,
f.prvdr_lctn_iid
FROM tax_entity_detail c,
provider_detail e,
provider_location f,
provider_location_detail pld
WHERE c.tax_entity_sid = e.tax_entity_sid
AND e.prvdr_sid = f.prvdr_sid
AND pld.prvdr_lctn_iid = f.prvdr_lctn_iid
AND c.oprtnl_flag = 'A'
AND c.status_cid = 2
AND e.oprtnl_flag = 'A'
AND e.status_cid = 2
AND (c.from_date) =
(SELECT MAX (c1.from_date)
FROM tax_entity_detail c1
WHERE c1.tax_entity_sid = c.tax_entity_sid
AND c1.oprtnl_flag = 'A'
AND c1.status_cid = 2)
AND (e.from_date) =
(SELECT MAX (c1.from_date)
FROM provider_detail c1
WHERE c1.prvdr_sid = e.prvdr_sid
AND c1.oprtnl_flag = 'A'
AND c1.status_cid = 2)
AND pld.oprtnl_flag = 'A'
AND pld.status_cid = 2
AND (pld.from_date) =
(SELECT MAX (a1.from_date)
FROM provider_location_detail a1
WHERE a1.prvdr_lctn_iid = pld.prvdr_lctn_iid
AND a1.oprtnl_flag = 'A'
AND a1.status_cid = 2)
Thank youPublished by: new learner on May 24, 2010 07:53
Published by: new learner on May 24, 2010 10:50
Can be like that not tested...
Select *.
Of
(
SELECT c.tax_idntfctn_nmbr irs_number, c.legal_name irs_name,
f.prvdr_lctn_iid, c.from_date as c_from_date, max (c.from_date) more (partition c.tax_entity_sid) as max_c_from_date,
e.from_date as e_from_date, max (e.from_date) more (partition e.prvdr_sid) as max_e_from_date,
PLD.from_date as pld_from_date, max (pld.from_date) more (pld.prvdr_lctn_iid partition) as max_pld_from_date
OF tax_entity_detail c,.
e provider_detail
provider_location f,
LDP provider_location_detail
WHERE c.tax_entity_sid = e.tax_entity_sid
AND e.prvdr_sid = f.prvdr_sid
AND pld.prvdr_lctn_iid = f.prvdr_lctn_iid
AND c.oprtnl_flag = 'A '.
AND c.status_cid = 2
AND e.oprtnl_flag = 'A '.
AND e.status_cid = 2
AND pld.oprtnl_flag = 'A '.
AND pld.status_cid = 2
) X
where c_from_date = max_c_from_date AND e_from_date = max_e_from_date AND
pld_from_date = max_pld_from_date
Tags: Database
Similar Questions
-
How to achieve using the analytical functions - please help
Oracle version: 10g
-999 means that all THE values for this keywith input_parameters as (select 10 filter_key , '10ACCC' filter_value from dual union all select 50 filter_key ,'10ACCC0001' filter_value from dual union all select 60 filter_key , 'PIP' filter_value from dual union all select 70 filter_key , 'A' filter_value from dual) select * from input_parameters; with profile_search as( select 100 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 100 profile_id , 50 filter_key , '10ACCC0001' filter_value from dual union all select 100 profile_id , 50 filter_key , '10ACCC0002' filter_value from dual union all select 100 profile_id , 60 filter_key , '999' filter_value from dual union all select 100 profile_id , 70 filter_key , '999' filter_value from dual union all select 101 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 101 profile_id , 50 filter_key , '10ACCC001' filter_value from dual union all select 101 profile_id , 60 filter_key , 'PIP' filter_value from dual union all select 101 profile_id , 70 filter_key , '999' filter_value from dual union all select 102 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 102 profile_id , 50 filter_key , '10ACCC0001' filter_value from dual union all select 102 profile_id , 60 filter_key , 'PIP' filter_value from dual union all select 102 profile_id , 70 filter_key , 'A' filter_value from dual) select filter_key , wm_concat(filter_value) from profile_search group by profile_id, filter_key ;
70 KEY HAS THE HIGHEST WEIGHT,need to identify profile that matches input parameters --------------------------------------------------------------------------- 102 is first match because it matches exactly 101 is second match because 999 can match any value 100 is third match
A next highest weight KEY 60 and 50 next highest weight BUTTON
required results:
profile_id: 102
Published by: devarade on January 19, 2010 20:01
Published by: devarade on January 19, 2010 20:01I guess that there is a typing error in your sample:
Select 101 profile_id, 50 filter_key, '10ACCC001' filter_value from all the double union
must be:
Select 101 profile_id, 50 filter_key, '01' filter_value from all 10ACCC00 the double union
Then:
with input_parameters as ( select 10 filter_key , '10ACCC' filter_value from dual union all select 50 filter_key ,'10ACCC0001' filter_value from dual union all select 60 filter_key , 'PIP' filter_value from dual union all select 70 filter_key , 'A' filter_value from dual ), profile_search as( select 100 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 100 profile_id , 50 filter_key , '10ACCC0001' filter_value from dual union all select 100 profile_id , 50 filter_key , '10ACCC0002' filter_value from dual union all select 100 profile_id , 60 filter_key , '999' filter_value from dual union all select 100 profile_id , 70 filter_key , '999' filter_value from dual union all select 101 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 101 profile_id , 50 filter_key , '10ACCC0001' filter_value from dual union all select 101 profile_id , 60 filter_key , 'PIP' filter_value from dual union all select 101 profile_id , 70 filter_key , '999' filter_value from dual union all select 102 profile_id , 10 filter_key , '10ACCC' filter_value from dual union all select 102 profile_id , 50 filter_key , '10ACCC0001' filter_value from dual union all select 102 profile_id , 60 filter_key , 'PIP' filter_value from dual union all select 102 profile_id , 70 filter_key , 'A' filter_value from dual ) select profile_id, sum(direct_match_cnt) || ' direct matches out of ' || (select count(*) from input_parameters) match from ( select b.profile_id, b.filter_key, b.filter_value, sum(case when b.filter_value = a.filter_value then 1 else 0 end) direct_match_cnt from input_parameters a, profile_search b where b.filter_key = a.filter_key and (b.filter_value = a.filter_value or b.filter_value = '999') group by b.profile_id, b.filter_key, b.filter_value ) x group by profile_id having count(*) = (select count(*) from input_parameters) order by sum(direct_match_cnt) desc / PROFILE_ID MATCH ---------- ---------------------------------------- 102 4 direct matches out of 4 101 3 direct matches out of 4 100 2 direct matches out of 4 SQL>
SY.
-
How to achieve this using the sql query?
Hello gurus,
I have a table like this
now my result should be like thisid name 1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h 9 i 10 j 11 k 12 l 13 m
How to achieve by sql query?id name id name id name 1 a 6 f 11 k 2 b 7 g 12 l 3 c 8 h 13 m 4 d 9 i 5 e 10 j
Thank you and best regards,
friend
Edited by: most wanted! February 22, 2012 05:55Hello
Did you mean this:
with a as (select 1 id ,'a' name from dual union all select 2 id ,'b' name from dual union all select 3 id ,'c' name from dual union all select 4 id ,'d' name from dual union all select 5 id ,'e' name from dual union all select 6 id ,'f' name from dual union all select 7 id ,'g' name from dual union all select 8 id ,'h' name from dual union all select 9 id ,'i' name from dual union all select 10 id ,'j' name from dual union all select 11 id ,'k' name from dual union all select 12 id ,'l' name from dual union all select 13 id ,'m' name from dual ) select id_1 ,name_1 ,id_2 ,name_2 ,id_3 ,name_3 from ( select id id_1 ,name name_1 ,lead(id,5) over (order by id) id_2 ,lead(name,5) over (order by id) name_2 ,lead(id,10) over (order by id) id_3 ,lead(name,10) over (order by id) name_3 ,rownum r from a ) where r <=5 D_1 NAME_1 ID_2 NAME_2 ID_3 NAME_3 ---------------------- ------ ---------------------- ------ ---------------------- ------ 1 a 6 f 11 k 2 b 7 g 12 l 3 c 8 h 13 m 4 d 9 i 5 e 10 j
Kind regards
Peter
-
How to achieve this using sql?
assume I have a below table and data create table sk_abcd (a varchar2(6), b varchar2(4)); insert into sk_abcd values ('abcdef', '1235'); insert into sk_abcd values ('qwert', '15'); commit; now I want output as below: <some query> a b -- -- ab 123 cd 5 ef null qw 15 er null t null
Hello
You don't give no matter what version of the database, or a clear explanation about the logic, so I just think that's what you want:
SQL> SELECT substr(a, 2*value(t)+1, 2) a, 2 substr(b, 3*value(t)+1, 3) b 3 FROM sk_abcd, 4 TABLE( 5 CAST( 6 MULTISET( select level-1 i from dual connect by level <= ceil(length(a)/2) ) 7 AS sys.odcinumberlist 8 ) 9 ) t 10 ; A B -------- ------------ ab 123 cd 5 ef qw 15 er t 6 rows selected
-
Is it possible to transfer videos from the iPod from someone else on my iPhone? How to achieve this?
Depends on the model of iPod exactly.
If the iPod is supported you can try using AirDrop: How to use with your iPhone, iPad or iPod touch - Apple Support AirDrop
If this is not the case, there are applications in the App Store that will allow you to send files, including videos taken with the iPod and who reside in the film to other devices.
https://iTunes.Apple.com/us/app/photo-transfer-app-easily/id365152940?Mt=8
Photo transfer app allows you to quickly copy pictures and videos from your iPhone, iPad, Mac or PC using your local wifi network.
You can't send videos that are stored by default Apple video App.
-
Oracle 11g Release 2
I'm assuming that the best solution is the use of analytical functions.
create table test3 ( part_type_id varchar2(50) ,group_id number ,part_desc_id number ,part_cmt varchar2(50) ) / insert into test3 values( 'ABC123',1,10,'comment1'); insert into test3 values( 'ABC123',1,10,'comment2'); insert into test3 values( 'ABC123',2,15,'comment1'); insert into test3 values( 'ABC123',2,15,'comment2'); insert into test3 values( 'EFG123',25,75,'comment3'); insert into test3 values( 'EFG123',25,75,'comment4'); insert into test3 values( 'EFG123',25,75,'comment5'); insert into test3 values( 'XYZ123',1,10,'comment6'); insert into test3 values( 'XYZ123',2,15,'comment7'); commit; select * from test3; PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 1 10 comment2 ABC123 2 15 comment1 ABC123 2 15 comment2 EDG123 25 75 comment3 EDG123 25 75 comment4 EDG123 25 75 comment5 XYZ123 1 10 comment6 XYZ123 2 15 comment7 9 rows selected. Desired output: PART_TYPE_ID GROUP_ID PART_DESC_ID PART_CMT -------------------- ---------- ------------ -------------------- ABC123 1 10 comment1 ABC123 2 15 comment1 XYZ123 1 10 comment1 XYZ123 2 15 comment2 RULE: where one part_type_id has multiple (2 or more distinct combinations) of group_id/part_desc_id NOTE: There are about 12 columns in the table, for brevity I only included 4.
Post edited by: orclrunner was updated desired output and rule
Hello
Here's one way:
WITH got_d_count AS
(
SELECT part_type_id, group_id, part_desc_id
MIN (part_cmt) AS min_part_cmt
COUNT AS d_count (*) OVER (PARTITION BY part_type_id)
OF test3
GROUP BY part_type_id, group_id, part_desc_id
)
SELECT DISTINCT
group_id, part_desc_id, part_type_id, min_part_cmt
OF got_d_count
WHERE d_count > 1
;
Output:
GROUP_ID PART_DESC_ID MIN_PART_CMT PART_TYPE_ID
------------ ---------- ------------ ------------
ABC123 1 10 comment1
ABC123 2 15 comment1
XYZ123 1 10 comment6
XYZ123 2 15 comment7
Analytical functions, such as the COUNTY and MIN, many global versions, in addition, it can give the same results. Use the analytical versions when each row of output corresponds to exactly 1 row of input and the aggregate and GROUP BY version when each line of output corresponds to a group of lines 1 or more input. In this issue, each line of output appears to be a group of input lines having the same group_id, part_type_id, and part_desc_id (I'm guessing just, this only has never stated), so I used GROUP BY to get 1 row of output for every input lines.
-
SQL using the analytic function
Hi allI want a help in the creation of my SQL query to retrieve the data described below:
I have a test of sample table containing data as below:
State ID Desc
MICHAEL 1 T1
ACTIVE 2 T2
T3 3 SUCCESS
DISABLE THE T4 4
The thing I want to do is to select all the lines with an ACTIVE status in the table but is there is no ACTIVE status, my request will give me the last line with MICHAEL status.
I can do this in a single request by using the analytical function for example, if yes can yiu help me on the request of unpacking.
Kind regards
Raluce
Something like that?
I had to fix it.
with testdata until)
Select 1 id, "T1" dsc "DISABLED" status of Union double all the
Select 2 id, 'T2' dsc, the status "ACTIVE" of all the double union
Select id 3, "T3" dsc, the status of 'SUCCESS' of all the double union
Select 4 id, "T4" dsc "DISABLED" status of double
)Select
ID
dsc
status
of testdata
where
status =
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then 'ACTIVE '.
Another 'DISABLED '.
end
and)
ID in (select id from testdata where status = ' ACTIVE')
or
ID = (select max (id) in testdata when status = 'DISABLED')
)STATE ID DSC
'2' 'T2' 'ACTIVE '.
Maybe it's more efficient
Select
ID
dsc
status
of testdata
where
status =
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then 'ACTIVE '.
Another 'DISABLED '.
end
and
ID =)
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then id
on the other
(select max (id) in testdata when status = 'DISABLED')
end
)Post edited by: correction of chris227
Post edited by: chris227
extended -
How to achieve this specific shadow effect?
Hi all
Does anyone know how to achieve this effect of specific shadow in InDesign: an instruction step by step, a plugin, etc.?
Kind regards
Kasyan
Kasyan,
I usually just use the base pen. I draw the object with a few clicks of the pen, fill it with whatever color, the hue value if you want, then use the settings more or less as below.
Mike
-
How to achieve this simple effect?
How to achieve this simple effect?
Hi guys,.
I just want to know what do you call the effect which the corners of the screen is blurred and darker, and how can we achieve?
See the video in this link www.youtube.com/watch?v=lHj83FRR11s.
Thank you in advance!
Use a solid layer of the color of your choice then add a mask and change his pen:
The effects coming from the photograph is called vignetting or vignnete
Another way is to add a bright spot and animated, but its more difficult, I hope it works
-
I had to replace my hard drive and need to reinstall Acrobat Pro. How to achieve this?
I had to replace my hard drive and need to reinstall Acrobat Pro. How to achieve this?
Hi Roger,
Please visit: http://www.adobe.com/downloads/other-downloads.html
I hope this helps.
Concerning
Megha Rawat
-
Original title: no local network connection
No links to the local area network connection. But how to use the Internet again, please help establish a LAN connection.
Hi H.mustafaakyurek,
· What operating system is installed on your computer?
You can view the following items on the creation of a network connection:
Setting up a network home
http://Windows.Microsoft.com/en-us/Windows7/setting-up-a-home-network
Start here to set up a home network in Windows 7
http://Windows.Microsoft.com/en-us/Windows7/start-here-to-set-up-a-home-network-in-Windows-7
Setting up a wireless network
http://Windows.Microsoft.com/en-us/Windows7/setting-up-a-wireless-network
Also see the following articles on the connection of an Internet connection:
What do I need to connect to the Internet?
http://Windows.Microsoft.com/en-us/Windows7/what-do-I-need-to-connect-to-the-Internet
Allows to connect to the Internet mobile broadband
http://Windows.Microsoft.com/en-us/Windows7/use-mobile-broadband-to-connect-to-the-Internet
Hope this information helps.
-
Remember - this is a public forum so never post private information such as numbers of mail or telephone!
Ideas: I have xp sp2 installed, I've upgraded to sp3 it settled and went to restart, but used to charge up please help
- You have problems with programs
- Error messages
- Recent changes to your computer
- What you have already tried to solve the problem
Hi mapo1477,
1. do you get an error at startup of the system?
2 have you tried to start the computer in safe mode?If you do not get any error message, then we recommend you to start your computer in safe mode and check if it starts successfully on the desktop. If it starts in safe mode, and then restore the computer. To do this, try the following steps:
a. see the description of the options course in Windows XP Startup Mode
b. Once you have started your computer in safe mode, restore the computer.
See How to restore Windows XP to a previous state
c. start the computer and check if the system starts in normal mode.To install Service Pack 3 successfully, see steps to take before you install Windows XP Service Pack 3
Visit our Microsoft answers feedback Forum and let us know what you think.
-
I have an email with attached wps files but I can't open them im using windows 7, someone please help
It is a Microsoft Works file you need a viewer for. Have a look here.
http://www.Microsoft.com/en-CA/Download/details.aspx?ID=4
I hope this helps.
-
I dug up a treasure box of old 35mm slides from 50-70 ' ies. Problem is that I can not understand how say that scans the slide or to look through, incidentally, without in mirror image. The slides that have alpha-numeric characters in the background are fairly easy, but those who don't kill me. Hoping someone here can give me some advice! Thanks in advance.
Chris
If they have been processed by Kodak and Kodak cardboard supports, the logo goes away from you when you look at the slide. In the case of plastic materials, they are often embossed with the text ' this side screen "on one side, or have some other difference evident between front and rear. I would take a peek at those you know are facing the right way and then others based on those in the case of similar media.
From: Adobe Forums [email protected]<>[email protected]>
Reply-To: "[email protected]<>[email protected]> ' [email protected]<>[email protected]>" "
Date: Saturday January 7, 2012 23:08:42 + 0000
To: default user Nam [email protected]<>[email protected]>
Topic: I'm havin' a time helluva determine how to scan 35mm slides... Please HELP!
I'm havin' a time helluva determine how to scan 35mm slides... Please HELP!
created by I Strugglin Mhttp://forums.adobe.com/people/IMStrugglin > in the application for Community assistance - see complete discussion onhttp://forums.adobe.com/message/4124282#4124282
-
ask for help I had to cancel a lot of Illustrator from adobe in this Bill at all. Please help me
Hello
Please refer to cancel your Adobe Creative Cloud membership
Incase you still need help please contact the support.
https://helpx.Adobe.com/contact.html
Concerning
Maybe you are looking for
-
I have problems with iMessage. I upgraded my iPod touch 5th generation iOS IOS 7 something 9.3.1. Account was opened to keep Messages forever. All messages are passed after the upgrade. Very well, we will live with the consequences, but would really
-
Laptop HP Pavilion 14 n201-tx: RAM upgrade for laptop HP Pavilion 14 n201-tx
I have a laptop HP Pavilion 14 n201-TX with 4 GB 1Rx8 RAM of PC3L - 12800S. The other location is empty. I want to upgrade the RAM to 8 GB or more. I have 2 questions: Can I buy a 8 GB of RAM and pair it with the existing 4 GB RAM? 2 should. what RA
-
How to access and control my firewall
I have Windows XP, SP3 with all updates installed on my computer. I have problems with a Web site - my browser find the URL and load the website, but the program never ask for my login details; and after a few seconds, the program displays the error
-
I lost my password to access the bios and set up the screen. How to retrieve or change the password. I am running vista Home premium 64-bit. original title: I lost my password
-
How & where to get help to stop him? Help!