TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anurag Srivastava
NA
39
0
Want to add value from different tables.
Jul 20 2012 7:49 AM
Hello All
I have a problem.
MY CHUNK CODE :
Insert
into
@Table145_1
select
Isnull
(
a
.
OilProducation
,
0
)
,
Isnull
(
b
.
FreeGasProducation
,
0
)
,
a
.
SrNo
from
(
select
SUM
(
IIndicatorTransaction
.
InputIndicatorValue
)
OilProducation
,
CMY
.
SrNo
from
CRMS_USER_Indicator_Region_Mapping
as
USERRegionMapping
inner
join
CRMS_InputIndicatorsTransaction IIndicatorTransaction
on
USERRegionMapping
.
UserIndicatorRegionMappingID
=
IIndicatorTransaction
.
UserIndicatorRegionMappingID
inner
join
CRMS_MonthYear CMY
on
CMY
.
MonthYear
=
IIndicatorTransaction
.
Indicator_Month
where
USERRegionMapping
.
IndicatorID
in(
272
)
and
USERRegionMapping
.
RegionID
in(
Select
CR
.
RegionId
from
CRMS_Region CR
where
CR
.
RegionId
in
(
Select
RegionId
from
CRMS_Region
where
(
ParentRegionID
=
@RegionID
)
or
(
RegionId
=
@RegionID
)))
and
CMY
.
MonthYearDate
between
@FirstMonth
and
@LastMonth
group
by
CMY
.
SrNo
)
a
full
join
(
select
SUM
(
IIndicatorTransaction
.
InputIndicatorValue
)
FreeGasProducation
,
CMY
.
SrNo
from
CRMS_USER_Indicator_Region_Mapping
as
USERRegionMapping
inner
join
CRMS_InputIndicatorsTransaction IIndicatorTransaction
on
USERRegionMapping
.
UserIndicatorRegionMappingID
=
IIndicatorTransaction
.
UserIndicatorRegionMappingID
Inner
join
CRMS_MonthYear CMY
on
CMY
.
MonthYear
=
IIndicatorTransaction
.
Indicator_Month
where
USERRegionMapping
.
IndicatorID
in(
273
)
and
USERRegionMapping
.
RegionID
in(
Select
CR
.
RegionId
from
CRMS_Region CR
where
CR
.
RegionId
in
(
Select
RegionId
from
CRMS_Region
where
(
ParentRegionID
=
@RegionID
)
or
(
RegionId
=
@RegionID
)))
and
CMY
.
MonthYearDate
between
@FirstMonth
and
@LastMonth
group
by
CMY
.
SrNo
)
b
on
a
.
SrNo
=
b
.
SrNo
When I am selecting ParentRegionId it shows multiple rows like (ParentRegioID =11, mapped with multiple regionID which is (12,13,35,37))
Suppose if I am putting the value of RegionId 12,13,35 and 37, It giving perfect Value.
RegionID= 12 ,Value= A,RegionID= 13,Value= B,RegionID= 35 ,Value= C,RegionID= 37 ,Value= D
But it is showing the value of ParentRegionID =11
But I want the Individual Summation of (A+B+C+D)
Pls help urgently
Thanks in Advance
Thanks and Regards
Anurag
Reply
Answers (
0
)
SQl Server Agent
i have loss my sqlserver2005 password how can i get can any one help me