![]() |
| |||||||
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
| ||||
| i have a table that has: pol_num, trn_code, new_pol_num now what i need to extract is any pol_num that has more than one 'Z' trn_code, but different new_pol_num ... something like this table data 123 -- Z -- 987 123 -- Z -- 876 456 -- Z -- 654 456 -- Z -- 654 in the above instance ... it would only return pol_num 123 since that has 2 different new_pol_num(s). any idea.
__________________ Quote of the Month: Strife: As long as we have each other, we'll never run out of problems. Questions to Ponder: Should vegetarians eat animal crackers? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright © 2008 sbenj69 |
| Sponsored Links |
| ||||
| Haven't tested this yet, but you sound desparate Code: select pol_num, new_pol_num from myTable where trn_code = 'Z' group by pol_num, new_pol_num having count(1) > 1
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
| ||||
| yeah...i think this is about the same or similar to Wolffy's. Code: SELECT pol_num, trn_code, Count(new_pol_num) AS Countnew_pol_num FROM mytable GROUP BY pol_num, new_pol_num HAVING (((trn_code)="z") AND ((Count(new_pol_num))>1)) Last edited by Rebelle; June 6th, 2008 at 02:59 PM. Reason: add code tags |
| ||||
| Code: select pol_num from (select distinct pol_num, new_pol_num from myTable where trn_code = 'Z') as A group by pol_num having count(pol_num) > 1 |
| The Following User Says Thank You to Wolffy For This Useful Post: | ||
mehere (June 6th, 2008) | ||
| ||||
| SELECT test.pol_num, test.trn_code, Count(test.new_pol_num) AS CountOfnew_pol_num, test.new_pol_num FROM test GROUP BY test.pol_num, test.trn_code, test.new_pol_num HAVING (((test.trn_code)="z") AND ((Count(test.new_pol_num))=1)); |
| ||||
| you are my own personal hero ... thanks muchly wolffy. here's what i ended up doing: Code: select full_pol, trn_dt, q_full_pol from dbo.HO_CONV_TRN where full_pol in (select full_pol from (select distinct Full_Pol, q_full_pol from dbo.HO_CONV_TRN where trn_code = 'z') as A group by Full_Pol having count(Full_Pol) > 1) and trn_code = 'Z' order by full_pol, q_full_pol |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Query Counts | Jaykappy | Microsoft Access | 13 | May 14th, 2008 01:39 PM |
| SQL VBA Query | Jaykappy | Microsoft Access | 12 | May 8th, 2008 09:30 AM |
| Sponsored Links |
| ASP.NET Resource Index a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer. Free Web Directory Including Chats and Forums Resources, Offer automatic, instant and free directory submissions. | URLZ Web Directory URLZ Web Directory Free Web Directory - Add Your Link The Little Web Directory | Free Web Directory Pegasus free web directory is a free directory organised by categories. Web Directory & SEO Services dirroot web directory |