Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have a table CLAIM_FNCL_TRANS that has the following fields OCCUR_NUMBER ACCOUNT_CD18 E18 I18 I18 E18 E18 E18 E18 EAnd I run the following script DROP TABLE #TEMP1SELECT C.OCCUR_NUMBERINTO #TEMP1---,O.OCCUR_STATUS_CDFROM CLAIM_FNCL_TRANS CGROUP BY C.OCCUR_NUMBER HAVING MAX (C.ACCOUNT_CD) = 'I'SELECT * FROM #TEMP1and Occur_number 18 does not get selected..
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2013-04-11 : 13:51:57
Say what?
DECLARE @CLAIM_FNCL_TRANS TABLE (OCCUR_NUMBER INT, ACCOUNT_CD CHAR(1))INSERT @CLAIM_FNCL_TRANS VALUES(18, 'E'),(18, 'I'),(18, 'I'),(18, 'E'),(18, 'E'),(18, 'E'),(18, 'E'),(18, 'E')SELECT C.OCCUR_NUMBERFROM @CLAIM_FNCL_TRANS CGROUP BY C.OCCUR_NUMBER HAVING MAX (C.ACCOUNT_CD) = 'I'-- ResultOCCUR_NUMBER------------18(1 row(s) affected)
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2013-04-12 : 04:37:51
do you've any other values also present for ACCOUNT_CD which you've not shown us?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs