The sub query i.e.
(
select MAX(D.ID)as id,D.Date,D.BREMPROCODE from dataupload D
where D.BREMPROCODE IN(SELECT BREMPROCODE FROM Dataupload
WHERE REGIONCODE='005') AND MONTH(date)=MONTH(GETDATE())
and day(date)=day(getdate()) GROUP BY D.Date,D.BREMPROCODE )x) ) as CurrentPrice
from Dataupload where REGIONCODE='005'
and MONTH(date)=MONTH(GETDATE()-1)and day(date)=day(getdate()-1) and time='7 PM'
returns more than value.
Pick the first one.
E.g.
(
select top 1 MAX(D.ID)as id,D.Date,D.BREMPROCODE from dataupload D
where D.BREMPROCODE IN(SELECT BREMPROCODE FROM Dataupload
WHERE REGIONCODE='005') AND MONTH(date)=MONTH(GETDATE())
and day(date)=day(getdate()) GROUP BY D.Date,D.BREMPROCODE )x) ) as CurrentPrice
from Dataupload where REGIONCODE='005'
and MONTH(date)=MONTH(GETDATE()-1)and day(date)=day(getdate()-1) and time='7 PM'