how to write a Query in Mysql -
i have 2 tables.ms_expese , track_expense.using table generate fact table want expense_name in ms_expense,expense_amount track_expense.
i want sum of expense_amount particular expense_name based on date.the date in order of 1,2...12 month id
select date_format(a.date,'%b') month_id,b.expense_name expense_type, sum(a.expense_amount) expense_amount ms_expense b join track_expense on a.`expense_id`=b.`expense_id` group date_format(a.date,'%b')
how put month id in order of 1,2,..12 , date format y-m-d month in apr,aug , on need jan 1,feb 2
i have 25 expenses(expense name).in query got total expense amount of first expense only.i want total expense of expenses in every month
create table fact (<your select query>)
your select query can in following form
select month(date)as month_id,expense_name,sum(expense_amount) ms_expense join track_expense using (expense_id) group expense_name,month(date)
Comments
Post a Comment