Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlnovice123
Constraint Violating Yak Guru
262 Posts |
Posted - 2011-07-28 : 23:04:21
|
| Hi,Using the below query with distinct returns two rows. But using having with group by should also return 2 rows correct?indicator HARP_ind7 U42 Nselect count(*) as indicator, case when (HARP_PRGM in ('Fannie Mae DU Refi Plus','Fannie Mae Refi Plus', 'Freddie LP Open Access','Freddie Mac Relief Refi') and LOAN_PURPOSE in ('Purchase','CASHOUT REFINANCE')) then 'Y' when HARP_PRGM in ('Fannie Mae DU Refi Plus','Fannie Mae Refi Plus', 'Freddie LP Open Access','Freddie Mac Relief Refi') then 'N' else 'U' end as HARP_ind from Fpdloanlist_may where Category in ('Agency')and Rollup_Channel in ('CORRESPONDENT','HLD','RETAIL','WHOLESALE') group by HARP_indhaving count(*) > 1indicator HARP_ind42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N42 N7 U7 U7 U7 U7 U7 U7 UOther than using DISTINCT, is there another way to get distinct groupings?Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-29 : 01:12:14
|
| I dont think posted query will work. You cant use aliases directly in your group by.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|