Sei sulla pagina 1di 6

select

a.doctype+ ' ' + cast(a.docno AS VARCHAR(10)) [Document No.],

b.FK_iwItemsREN [Item Code],

dbo.udf_getitemdescription(b.FK_iwItemsREN) [Item Description],

b.renqty [Quantity],

a.rendate AS DATE,

dbo.udf_GetFullName(a.fk_emdpatients) [Name of Patient],

CASE

when a.pattrantype = 'I' then 'Inpatient'

when a.pattrantype = 'O' then 'Outpatient'

else 'Emergency'

end as [Patient Type],

dbo.udf_GetFullName(a.FK_ASURenUser) [Render By]

from pspatinv A

inner join

psPatitem B on b.FK_TRXNO = a.PK_TRXNO

where

b.FK_iwItemsREN = 'MED00155'

and convert(varchar, a.rendate, 120) between '2018-09-14 00:00:01' and '2018-09-14 23:59:59'

order by DATE, [Name of Patient], [Document No.]

select dbo.udf_GetFullName(FK_ASURenUser) as name

from

pspatinv
where

dbo.udf_GetFullName(FK_ASURenUser) like '%LEE, JHOANA LIEZEL ODULIO%'

select

PK_TRXNO,

STINo,

itemid,

itemdesc,

qty,

WarehouseDST,

WarehouseSCR,

STIDate,

UserLog,

remarks

from

vwReportStockIssuance

where itemdesc = 'LYSOL SPRAY 510G'

select * from vwReportStockIssuance where UserLog = 'LOPEZ, ANGELA P.' and STINo = '13850'

select

a.IssNo,
a.ItemDesc,

a.qty,

a.IssDept,

a.ReqDept,

a.IssDate,

a.ExReqDate,

a.UserLog,

a.remarks

from

vwReportExpenceIssuance a

where

a.UserLog = 'LEE, JHOANA LIEZEL ODULIO'

group by a.IssNo,

b.itemid,

a.ItemDesc,

a.qty,

a.IssDept,

a.ReqDept,

a.IssDate,

a.ExReqDate,

a.UserLog,

a.remarks
select

PK_TRXNO,

STINo,

itemid,

itemdesc,

qty,

WarehouseDST,

WarehouseSCR,

STIDate,

UserLog,

remarks

from

vwReportStockIssuance

where

UserLog = @name

and convert(varchar, STIDate, 101)

between @pDateRangeFrom and @pDateRangeTo

--crit level with balance

select PK_iwitems as [Item Id],

dbo.udf_GetItemDescription(a.PK_iwitems) as [Item
Descripton],

c.description as [Department Name],

a.itemgroup as [Item Group],


d.description as [Item Category],

a.lowinven as [Critical Level],

b.purcqty - b.purcretqty - b.salesqty + b.salesretqty + b.adjinqty


- b.adjoutqty

+ b.reqinqty - b.reqoutqty + b.prodqty - b.prodoutqty +


b.purcretinqty + b.issinqty

- b.purcoutqty - b.issoutqty as [Balance],

isnull(a.lastpurcprice,0) as [Purchase Price],

isnull((b.purcqty - b.purcretqty - b.salesqty + b.salesretqty +


b.adjinqty -

b.adjoutqty + b.reqinqty - b.reqoutqty + b.prodqty -


b.prodoutqty + b.purcretinqty + b.issinqty

- b.purcoutqty - b.issoutqty)* a.lastpurcprice,0) as Amount

from iwitems a inner join iwWareitem b on a.PK_iwItems =


b.FK_iwItems

inner join mscwarehouse c on b.fk_mscwarehouse =


c.pk_mscwarehouse

inner join mscitemcategory d on a.fk_mscitemcategory


= d.pk_mscitemcategory

where a.PK_iwItems = 'MED01167'

and c.description = 'PHARMACY'

----------final

select DISTINCT B.FK_iwItemsREN [Item Code],

e.doctype+ ' ' + cast(e.docno AS VARCHAR(10)) [Document


No.],

dbo.udf_getitemdescription(b.FK_iwItemsREN),

renqty [Quantity],

D.lowinven as [Critical Level],


a.purcqty - a.purcretqty - a.salesqty + a.salesretqty + a.adjinqty -
a.adjoutqty

+ a.reqinqty - a.reqoutqty + a.prodqty - a.prodoutqty +


a.purcretinqty + a.issinqty

- a.purcoutqty - a.issoutqty as [Balance]

from iwWareitem a

LEFT join psPatitem b on a.FK_iwItems = b.FK_iwItemsREN

inner join mscwarehouse c on A.fk_mscwarehouse =


c.pk_mscwarehouse

inner join iwitems D on D.PK_iwItems = A.FK_iwItems

inner join pspatinv e on b.FK_TRXNO = e.PK_TRXNO

where b.itemgroup in ('SUP','MED')

and c.description = 'PHARMACY'

and convert(varchar, e.rendate, 120) between '2018-09-18


00:00:01' and '2018-09-18 23:59:59'

and b.FK_iwItemsREN = 'MED00887'

Potrebbero piacerti anche