jeudi 5 mars 2015

Issue in join query of multiple tables sqlite

hello friends i have four tables as below



property_master --> "p_id" , "p_name" , "p_address" , "p_city" , "p_state" ,"r_id"

property_unit -->"unit_id" , "p_id" , "unit_name" ,"r_id"

unit_info --> "unit_info_id" ,"unit_id" INTEGER,"p_id" ,"p_bathroom" ,"p_bedroom" ,"p_size" ,"p_rent" ,"p_isrent" ,"u_note" ,"r_id"

tanant_master --> "t_id" , "t_name" ,"t_cell_no" ,"t_phone_no" ,"t_mail" ,"t_deposit" ,"r_id"

property_assign--> "t_assign_id" , "unit_info_id" , "t_id" , "t_start_date" , "t_end_date" , " t_rent_due_day" , "t_lease_alert" , "t_status" ,"r_id"


and my query is as below



Select p_name As "Property",
p_id AS "PID",
(Select Count(unit_id) from property_unit where property_master.p_id=property_unit.p_id )As "UnitCount",
(Select Count(unit_info_id) from unit_info where unit_info.unit_info_id=property_assign.unit_info_id )As "TenantCount"
From property_master ,property_assign Group by property_master.p_id


i need total tenant count propertywise but when i run above query it gives me only first property tenant count for all property any idea how can i solve it?


Aucun commentaire:

Enregistrer un commentaire