SQLTeam.com | Weblogs | Forums

How to get One record


#1

Extension for the above question.

How to get a single record fro

m the two records.


#2

I think this might work for you:

select l.leaid as dstid
      ,max(case when agsh.statisticname='LEPCUR' then agsfh.value else null end) as lepcur
      ,max(case when agsh.statisticname='LEPFS' then agsfh.value else null end) as lepfs
      ,agsh.schoolyear as sy
  from sif.objaggregatestatistic as agsh
       inner join sif.objaggregatestatisticfact as agsfh
               on agsfh.statisticrefid=agsh.refid
              and agsfh.collectionid=agsh.collectionid
       inner join edfusionods.sif.lea as l
               on l.refid=agsh.learefid
 where agsh.statisticname in ('LEPCUR','LEPFS')
 group by l.leaid
         ,agsh.schoolyear
;

#3

Thanks for the Update ,

It is working as expected.