Author |
Topic |
ramuu
Starting Member
7 Posts |
Posted - 2013-05-14 : 07:45:37
|
I have a table for which I want to validate where each parent intermediary is also a parent to itself. How to write query to validate this?COLUMN DATATYPE DESCRIPTIONIntermediaryPK int SourceSystemID tinyint Intermediary sourceIntermediaryID nvarchar(20) Intermediary IDIntermediaryName nvarchar(200) Intermediary nameIntermediaryTypeID nvarchar(1) Intermediary typeParentIntermediaryID nvarchar(20) Intermediary parentIntermediaryTypePK tinyint Intermediary typeIntermediaryCategoryPK smallint Intermediary categoryParentIntermediaryPK int Parent intermediary PKGrandParentIntermediaryPK int Grand parent intermediary PK |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-14 : 08:03:22
|
can you show some sample data to illustrate how relationship exists and explain what you want to validate?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
ramuu
Starting Member
7 Posts |
Posted - 2013-05-14 : 08:22:51
|
Hi visakh16Here is the sample dataIntermediaryPK SourceSystemID IntermediaryID IntermediaryName IntermediaryTypeID IsActive LicenseID ParentIntermediaryID IntermediaryTypePK IntermediaryCategoryPK ParentIntermediaryPK GrandParentIntermediaryPK6768 1 200509907481 IBL-BANK-KERALA-PALAKKAD C 1 NULL 201804759375 2 5 5440 NULL6769 1 201837486436 ALLFIN - KERALA- PALLAKAD C 0 NULL 202072185454 2 5 5441 NULL6770 1 200754186125 IBL-VFD-KERALA- NORTH-MALAPPURAM C 0 NULL 2018047593750001 2 5 4870 197586771 1 201521454945 ALLFIN - KERALA- TRISSUR C 0 NULL 202072185454 2 5 5441 NULL6772 1 200917687453 ALLFIN -TAMILNADU-MADURAI- TUTICORIN C 0 NULL 202072185454 2 5 5441 NULL6773 1 201211783821 IBL-IMFSL-TAMILNADU-TIRUNELVELI C 0 NULL 200891460243 2 5 6619 NULLI just need to validate whether each parent intermediary is also a parent to itself. I think the query should be in format likeSELECT XFROM YWHERE Z IS NULL |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
ramuu
Starting Member
7 Posts |
Posted - 2013-05-15 : 02:11:21
|
Hi visakh16Here is the sample dataintermediarypk intermediaryid parentintermediaryid parentintermediarypk grandparentintermediarypk37 2003840093340001 NULL NULL NULL38 200279839266 NULL NULL NULL39 201995093279 NULL NULL NULL40 200003615409 201951376189 4005 NULL41 201336769172 201951376189 4005 NULL42 201441882733 201282938485 6460 NULL.........I just need to validate whether each parent intermediary is also a parent to itself. I think the query should be in format likeSELECT XFROM YWHERE Z IS NULL |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-15 : 02:17:33
|
what do you mean by parent to itself? do you mean a self relationship like ID->ID?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
ramuu
Starting Member
7 Posts |
Posted - 2013-05-15 : 02:52:21
|
yes.....I want to validate where each intermeiary parent's will be intermediary parent itself. I want to write query for this.... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-15 : 03:46:06
|
so for above sample data what would be the output? show atleast one case where you've this relationship existing------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
ramuu
Starting Member
7 Posts |
Posted - 2013-05-15 : 04:30:11
|
`Hi visakh16, Thats what I want to validate this. This query should not give any output. It should only validate each parent intermediary is also a parent to itself. foe ex. If I want to 'Validate each client has a valid gender' I hace written a query which is:SELECT * FROM CLIENTWHERE ISNULL(ClientGenderName,'') NOT IN (SELECT ISNULL(Gender,'') FROM PARTY_DETAILS)So the query format will be like this for our task, and this query will not give any output, It just give column names.... |
|
|
|