This post can explain the SQL Tables many topics single handly like Join , groups, where clause , case, distinct
Top 100+ Sql Server Interview Questions
// Field Details
@fromdate,
@todate,
c.GroupName,
a.sr_no,
a.ac_shortname,
a.ac_name,
abs(sum(debit_amount)-sum(credit_amount)) as "Closing",
Case
when convert(money,(sum(debit_amount)- sum(credit_amount)
)
) >= 0
then ' Dr'
Else ' Cr' End
as "Credit_Debit"
// Tables Details
from acct_mast a
inner join bsgroup_master c
on a.co_code=c.co_code
and a.gr_code=c.code
inner join ledr_data b
on a.CO_CODE=b.CO_CODE
and a.SR_NO=b.AC_CODE
where a.CO_CODE =@Prm_Co_Code
and b.fyear = @fyear
and
(b.payment_status = 'Approved' or trans_type = 'o')
and b.Voucher_Date>=@fromdate
and b.Voucher_Date<=@todate
and GroupName='Sundry Creditors'
and a.AC_TYPE in('Supplier')
and isnull(a.ac_shortname,'')!=''
group by c.GroupName,
a.sr_no,
a.ac_shortname,
a.ac_name
No comments:
Post a Comment