나는 두 날짜 사이의 최소 금액을 얻기위한 몇 가지 논리, 내가 '2017-12-31'.I을'2017년 12월 1일 '사이의 각 예금의 균형 적어도 원하는Sql을 사용하여 두 날짜 사이의 최소 금액을 얻는 방법?
create table #tmp(id int,deposit_id int,transaction_amount decimal(15,2),trn_date date,trn_type varchar(50));
insert into #tmp
select 1,101,15000,'2017-12-01','Receipt' -- 15000
union all
select 2,101,-5000,'2017-12-09','Payment' -- 10000
union all
select 3,101,6000,'2017-12-16','Receipt' --16000
union all
select 4,101,-15000,'2017-12-20','Payment' -- 1000
union all
select 5,101,10000,'2017-12-22','Receipt' --11000
union all
select 5,101,-1000,'2017-12-22','Payment' --10000
union all
--- another deposit details
select 55,102,50000,'2017-12-04','Receipt' -- 50000
union all
select 56,102,5000,'2017-12-10','Receipt' -- 55000
처럼 내 테이블이 필요 내가 어떻게 2017-12-24'.Please '에, 예를 들어 하루에 잔액을 확인할 수 있기 때문에 캔트이 결과를 얻기 위해 쿼리에 대한 논리를 얻을 줄 몇 가지 tips.My 원하는 결과는
deposit_id date LeastAmt
101 - '2017-12-20' - 1000
102 - '2017-12-04' - 50000
선생님은 내가 오류 'D2'에 대한 –
@PrasannaKumarJ 오타't2.transaction_amount'을 bound.' 할 수없는 여러 부분으로 구성된 식별자 "t2.transaction_amount"를 얻었다. transaction_amount' –