select TAX.ITSID as TAXID,  sum(ITSTOTAL * ITSPERCENTAGE) as TOTALTAX
from PURCHASEINVOICELINE 
join INVITEMSUPPLIERTAXLINE on INVITEMSUPPLIERTAXLINE.ITSOWNER = PURCHASEINVOICELINE.INVITEM 
join TAX on TAX.ITSID = INVITEMSUPPLIERTAXLINE.ITSTAX
where PURCHASEINVOICELINE.ITSOWNER = 1 
group by TAX.ITSID;

select WAREHOUSEENTRY.ITSQUANTITY as WAREHOUSEENTRYITSQUANTITY, WAREHOUSEENTRY.ITSID as WAREHOUSEENTRYITSID, 
WAREHOUSEENTRY.SOURCEID as WAREHOUSEENTRYSOURCEID, INVITEM.ITSNAME as INVITEMITSNAME, 
INVITEM.ITSID as INVITEMITSID, INVITEM.TAXESDESCRIPTION as INVITEMTAXESDESCRIPTION, INVITEM.IDBIRTH as INVITEMIDBIRTH, 
INVITEM.KNOWNCOST as INVITEMKNOWNCOST, INVITEM.SUPPLIERTAXESDESCRIPTION as INVITEMSUPPLIERTAXESDESCRIPTION, INVITEM.ITSCATEGORY as INVITEMITSCATEGORY, 
INVITEM.IDDATABASEBIRTH as INVITEMIDDATABASEBIRTH, INVITEM.ITSVERSION as INVITEMITSVERSION, WAREHOUSEENTRY.IDBIRTH as WAREHOUSEENTRYIDBIRTH, 
WAREHOUSEENTRY.IDDATABASEBIRTH as WAREHOUSEENTRYIDDATABASEBIRTH, WAREHOUSEENTRY.ITSVERSION as WAREHOUSEENTRYITSVERSION, 
WAREHOUSESITETO.ITSID as WAREHOUSESITETOITSID, WAREHOUSESITETO.ITSNAME as WAREHOUSESITETOITSNAME, WAREHOUSESITETO.WAREHOUSE as WAREHOUSESITETOWAREHOUSE, 
WAREHOUSESITEFROM.ITSID as WAREHOUSESITEFROMITSID, WAREHOUSESITEFROM.ITSNAME as WAREHOUSESITEFROMITSNAME, WAREHOUSESITEFROM.WAREHOUSE as WAREHOUSESITEFROMWAREHOUSE,
WAREHOUSEENTRY.SOURCETYPE as WAREHOUSEENTRYSOURCETYPE
from WAREHOUSEENTRY 
left join INVITEM on WAREHOUSEENTRY.INVITEM=INVITEM.ITSID 
left join WAREHOUSESITE as WAREHOUSESITETO on WAREHOUSEENTRY.WAREHOUSESITETO=WAREHOUSESITETO.ITSID 
left join WAREHOUSESITE as WAREHOUSESITEFROM on WAREHOUSEENTRY.WAREHOUSESITEFROM=WAREHOUSESITEFROM.ITSID 
where SOURCETYPE=2 and SOURCEID=2;

select ITSUSER.ITSNAME as ITSUSERITSNAME, 
ITSUSER.ITSID as ITSUSERITSID, ITSUSER.IDBIRTH as ITSUSERIDBIRTH, ITSUSER.ITSPASSWORD as ITSUSERITSPASSWORD, 
ITSUSER.IDDATABASEBIRTH as ITSUSERIDDATABASEBIRTH, ITSROLE.ITSNAME as ITSROLEITSNAME, 
ITSROLE.ITSID as ITSROLEITSID, ITSROLE.IDBIRTH as ITSROLEIDBIRTH, ITSROLE.IDDATABASEBIRTH as ITSROLEIDDATABASEBIRTH
from USERROLEJETTY left join USERJETTY as ITSUSER on USERROLEJETTY.ITSUSER=ITSUSER.ITSID left join ROLEJETTY as ITSROLE on USERROLEJETTY.ITSROLE=ITSROLE.ITSID where ITSUSER=1 and ITSROLE=1;
