程式名稱:ACOK_Unit



--銷售筆數

select count(salno) as salno from  m_salesh where stno='004' and isacc=0 and salno like 'SU%'

--銷售件數

select count(buynum) as salno from  m_salesd where stno='004'  and isacc=0 and salno like 'SU%'

--銷售總額

select sum(total) as toamt  from  v_salesh where stno='004' and isacc=0 and salno like 'SU%'

--銷退件數

select count(salno) as salno from  m_salesh where stno='004' and  isacc=0  and salno like 'RT%'

--銷退總額

select sum(total) as toamt  from  v_salesh where stno='004' and isacc=0 and salno like 'RT%'

--現銷

select sum(total) as toamt  from  m_salesh where stno='004' and isacc=0  and accWay='1' and salno like 'SU%'

--賒銷

select sum(total) as toamt  from  m_salesh where stno='004' and isacc=0 and accWay='2' and salno like 'SU%';

--押金

select  sum(a.press) as press  from  m_salesd a  left join m_items  b on a.merno=b.merno  where a.stno='004' and a.isacc=0;

--現金

select sum(amt) as toamt  from  m_paydtl where stno='004' and isacc=0 and payid='01';

--支票

select sum(amt) as toamt  from  m_paydtl where stno='004' and isacc=0 and payid='02';

--匯款

select sum(amt) as toamt  from  m_paydtl where stno='004' and isacc=0 and payid='06';

--交易折讓

select sum(discnt) as discnt  from  m_salesd where stno='004' and isacc=0;

--月結應收 = 賒銷

select sum(total) as toamt  from  m_salesh where stno='004' and isacc=0 and accWay='2' and salno like 'SU%';

--非月結應收 = 現銷

select sum(total) as toamt  from  m_salesh where stno='004' and isacc=0 and accWay<>'2' and salno like 'SU%';

--收回欠款

select sum(amt) as toamt  from  m_paydtl where stno='004' and isacc=0 and psmode=3;

--實際收入

select sum(amt) as toamt  from  m_paydtl where stno='004' and isacc=0 ;

--支出

select sum(total) as total  from  m_apdtl where stno='004' and isacc=0;

--應餘

現銷-支出


結帳寫入資料表:m_salsht



Created with the Personal Edition of HelpNDoc: Easy to use tool to create HTML Help files and Help web sites