0
年と株コードを入力できるようにするレポートを作成しています。レポートには、ユーザーからの選択された年の1月から12月までのアイテムの月間売上が表示されます。データが存在しない場合でも、結果はすべて12か月間でなければなりません。年のレコードを1月から12月までの間で一覧表示する方法
set @yyyy = 2016;
select date_format(bb.bill_date, '%m/%y') as date_1, sum(bb.Qty), stockcode
from
(
select 1 as srce, zz.qty Qty, zz.stkcode stockcode, ll.bill_date bill_date
FROM posbila ll, posbilb zz
WHERE
ll.bill_no = zz.receive_ID
AND
zz.stkcode >= '0'
AND
zz.stkcode <= 'zz'
AND
date_format(ll.billdate,"yyyy") = 2016
group by zz.StkCode, ll.bill_date
union select 2, 0, concat(@yyyy,'-01-31')
union select 2, 0, concat(@yyyy,'-02-01')
union select 2, 0, concat(@yyyy,'-03-31')
union select 2, 0, concat(@yyyy,'-04-30')
union select 2, 0, concat(@yyyy,'-05-31')
union select 2, 0, concat(@yyyy,'-06-30')
union select 2, 0, concat(@yyyy,'-07-31')
union select 2, 0, concat(@yyyy,'-08-31')
union select 2, 0, concat(@yyyy,'-09-30')
union select 2, 0, concat(@yyyy,'-10-31')
union select 2, 0, concat(@yyyy,'-11-30')
union select 2, 0, concat(@yyyy,'-12-31')
) as bb
left join icstk kk on bb.stockcode = kk.stockcode
Group By 1, date_1
I have this query :
date_1 stkcode Qty stockcode description
02/16 COKE 13 COKE COKE123
03/16 COKE 112 COKE COKE123
04/16 COKE 6 COKE COKE123
06/16 COKE 5 COKE COKE123
しかし、私は何かしたい:
date_1 stkcode Qty stockcode description
01/16 0
02/16 COKE 13 COKE COKE123
03/16 COKE 112 COKE COKE123
04/16 COKE 6 COKE COKE123
05/16 0
06/16 COKE 5 COKE COKE123
07/16 0
08/16 COKE 5 COKE COKE123
09/16 0
10/16 0
11/16 COKE 15 COKE COKE123
12/16 COKE 25 COKE COKE123
Hmm..looks http://stackoverflow.com/questions/38474796/how-to-select-data-of-に類似しますユーザが選択したすべての月間の空白/ 38476280?noredirect = 1#comment64399944_38476280。 –
暗黙的な結合を明示的な結合に変更する必要があります。ユーザーが日付を設定できるようにするには、mysqlにタグが付いているので、コードやmysqlにアクセスする必要があります.PPのようなフロントエンドはありますか? –
私はウィンドウのフォームでVBを使用します。 – Chloe