Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8635

Re: Need Help On this Query

$
0
0

Hi Nabil,

Try This Query...

 

DECLARE @Date AS DATETIME
DECLARE @Series AS varchar(30)
DECLARE @Branch AS varchar(30)
DECLARE @Exec AS varchar(30)

/* SELECT FROM [dbo].[OINV] S0 WHERE */ SET  @Date = /* S0.DocDate*/ '[%0]'

/* SELECT FROM [dbo].[NNM1] S2 WHERE */ SET  @Series = /* S2.SeriesName*/ '[%2]'

/* SELECT FROM [dbo].[OLCT] S3 WHERE */ SET  @Branch = /* S3.Location*/ '[%3]'

/* SELECT FROM [dbo].[OSLP] S4 WHERE */ SET  @Exec = /* S4.SlpName*/ '[%4]'

 

if( @Exec ='') set @Exec ='%'
if( @Series ='') set @Series ='%'
if( @Branch ='') set @Branch ='%'
if( @Date ='') set @Date =GETDATE()
Select distinct OINV.DocNum,OINV.CardName [Customer Name], ISNULL(NNM1.SeriesName ,'-')+'/'+ CAST(OINV.DocNum as varchar) [Bill No.],
OINV.DocDate [Bill Date],
OINV.DocTotal - OINV.PaidToDate [Out Standing Amount],
DATEDIFF(dd,OINV.DocDate,@Date)[No of Days]  from OINV
inner join INV1 on OINV.DocEntry = INV1.DocEntry
inner join OLCT on INV1.LocCode = OLCT.Code
inner join NNM1 on OINV.Series = NNM1.Series
inner join OSLP on OINV.SlpCode = OSLP.SlpCode 
where OINV.DocType ='I' and (OINV.DocTotal - OINV.PaidToDate)>0
and NNM1.SeriesName like @Series and OINV.DocDate<= @Date
and OLCT.Location like @Branch and OSLP.SlpName like @Exec


Viewing all articles
Browse latest Browse all 8635

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>