| Author |
Topic |
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-03-16 : 05:49:26
|
| Hi all,My table structure is like this . i hae copied only sample data over here like this datai have more than 500. here i have to select entrytype_id which will repeat for article_type_id, i am totally cofusedhow to select the datas from this table with this conditiontable structure is like this....Article_Pdf_ID Article_Type_ID EntryType_ID IsDeleted IsActivated Modified by4 24 2 1 0 3875 24 15 0 1 3876 24 4 1 0 3877 24 5 1 0 3878 24 6 1 0 3879 24 7 0 1 38712 24 8 0 1 38713 43 9 1 0 38714 35 10 1 0 38715 25 1 1 0 38716 25 2 1 0 38717 25 3 1 0 38718 25 4 1 0 38719 25 5 1 0 38720 29 1 1 0 387Regards,Divya |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-03-16 : 06:06:32
|
| can u post required sample output |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-03-16 : 06:28:31
|
quote: Originally posted by bklr can u post required sample output
This sample data for where entry type is 15, like this there are many entrytpe_id is there which will repeat i want to display ArticleType_id and Entrytype_id forEntrytype_id which will repeat..i think scenario is clear now.. please let me know if any query .....Article_Type_ID EntryType24 1526 1525 1527 1528 1529 1530 1531 1532 15Regards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 06:43:36
|
do you mean this?SELECT t.Article_Type_ID, EntryType_IDFROM Table tINNER JOIN (SELECT EntryType_ID,COUNT(*) AS Occurance FROM Table GROUP BY EntryType_ID)t1ON t.EntryType_ID=t1.EntryType_IDAND t1.Occurance > 1 [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-03-16 : 06:44:28
|
| select distinct Article_Type_ID ,EntryType from tablename |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 07:01:55
|
quote: Originally posted by bklr select distinct Article_Type_ID ,EntryType from tablename
how do you think it will cover following reqmnt?there are many entrytpe_id is there which will repeat i want to display ArticleType_id and Entrytype_id forEntrytype_id which will repeat..------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-03-16 : 07:24:11
|
quote: Originally posted by visakh16
quote: Originally posted by bklr select distinct Article_Type_ID ,EntryType from tablename
how do you think it will cover following reqmnt?there are many entrytpe_id is there which will repeat i want to display ArticleType_id and Entrytype_id forEntrytype_id which will repeat..------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thank u!!That is working fine.....One more condition is needed, there are more than 30 Article_Type_ID in the tablefor eg if EntryType_ID 15 will there for every Article_Type_ID i have to find the all EntryType_ID which will be for these whole Article_Type_ID's i have done code like thisSELECT distinct(EntryType_ID) FROM FIS_ArticleType_ProvisionalPdf group by Article_Type_ID,EntryType_IDhaving COUNT(EntryType_ID)<29here i know the count of distinct(Article_Type_ID)is 29 ie is y i have given like this, how i can find the distinct count over thereRegards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 07:29:59
|
| you want to find the distinct count of associated Article_Type_ID for each of repeating Entry_Level_ID?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 07:35:22
|
if yesSELECT EntryType_ID,COUNT(*) AS OccuranceFROM TableGROUP BY EntryType_IDHAVING COUNT(DISTINCT Article_Type_ID)<(SELECT COUNT(DISTINCT Article_Type_ID) FROM Table) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-03-16 : 07:37:29
|
quote: Originally posted by visakh16 you want to find the distinct count of associated Article_Type_ID for each of repeating Entry_Level_ID?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
I have to display all EntryType_ID which will be there in all Article_Type_IDother i don't want to display....Regards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 07:46:50
|
ok then it should beSELECT EntryType_IDFROM TableGROUP BY EntryType_IDHAVING COUNT(DISTINCT Article_Type_ID)=(SELECT COUNT(DISTINCT Article_Type_ID) FROM Table) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2010-03-16 : 08:01:49
|
quote: Originally posted by visakh16 ok then it should beSELECT EntryType_IDFROM TableGROUP BY EntryType_IDHAVING COUNT(DISTINCT Article_Type_ID)=(SELECT COUNT(DISTINCT Article_Type_ID) FROM Table) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
wow!!!! it worked thank u visakh!!!!!!Regards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-16 : 08:10:15
|
welcome (as always) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|