jeudi 9 avril 2015

Issue in get Total value and field name null in join SQLITE android

Hello friends i have 6 tables



property_master -->p_id, p_name, p_address,p_city,P_state,p_country,p_is_active


tanant_master-->t_id,p_id,t_name,


property_unit--> unit_id,p_id,unit_name


unit_info-->unit_info_id,unit_id,p_id,p_rent, p_isrent


property_assign-->m_id,p_id,m_total,m_date


transction_master-->t_master_id,p_id,unit_info_id ,t_id ,user_cat_id,amount,date


My requirement is i need all list of property and unit information which i have suppose i have 3 property and in first property A include 2 unit like A1,A2 than i need list like A,A1,A2 and all information about that so i make query for that


Query



SELECT property_master.p_id AS "PID",
property_master.p_name AS "PropertyName",
property_master.p_address AS "ProepertyAddress",
property_master.p_city AS "ProepertyCity",
property_master.p_state AS "ProepertyState",
property_master.p_country AS "ProepertyCountry",
tanant_master.t_name AS "TanantName",
property_unit.unit_name as "unit_name",
(SELECT SUM(amount)
FROM transction_master
WHERE unit_info_id = unit_info.unit_info_id and transction_master.date
between '2015-01-01' and '2015-12-31'
) AS "TotalIncome",
(SELECT SUM(amount)
FROM transction_master
WHERE unit_info_id = unit_info.unit_info_id and transction_master.date
between '2015-01-01' and '2015-12-31'
) AS "TotalExpense"
FROM property_master left join transction_master on property_master.p_id = transction_master.p_id left join property_assign on
(property_master.p_id=property_assign.p_id)
left join tanant_master on
(tanant_master.t_id=property_assign.t_id)
left join unit_info on
(unit_info.unit_info_id=transction_master.unit_info_id)
left join property_unit on property_unit.unit_id = unit_info.unit_id
where property_master.p_is_active=0 and property_master.r_id=75
GROUP BY property_master.p_id ,tanant_master.t_id


When i run above query it give list of only main property which i have not unit name and also TOtalIncome ,TotalExpense, getting null , but i have so any idea how can i solve it?


Aucun commentaire:

Enregistrer un commentaire