Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Trying to merge multiple tables and group by

$
0
0

Hi,

i need help to query below all 4 tables and finally grouped by ITEM_INSPECTED. so basically trying to get one row instead of three row from condition table. so far i was able to query only condition table using below script but i want to merge all tables and result will be like below.

PROJECT_NUMBERPHYSICAL_INSPECT_DATEPHY_CONDCATEGORYDEFICIENCY_CODELIFE_SAFETYON_PRIOR_REPREPAIR_TIME
6000026/8/2018EXTERIORFlashingC*Y8

select project_num,physical_inspect_date,min(deficiency_code), max(life_safety),max(on_prior_rep),max(repair_time)
from CONDITION
where project_num='600002' and physical_inspect_date='8-JUNE-2018'
group by project_num,physical_inspect_date

CONDITION:

PROJECT_NUMBERPHYSICAL_INSPECT_DATECATEGORYDEFICIENCY_CODELIFE_SAFETYON_PRIOR_REPREPAIR_TIMEDEFICIENCY_ID
6000026/8/2018FlashingC*N824
6000026/8/2018DrainsM*Y427
6000026/8/2018VentsCN630

COND_DEFICIENCY:

DEFICIENCY_IDCATEGORY_IDDEFICIENCY
245Repair damaged aluminum counter flashing
276Replace missing drain caps
307Repair the damaged vent cover located

COND_CATEGORY:

CATEGORY_IDCATEGORYITEM_INSPECTED
5Flashing2
6Drains2
7Vents2

ITEMS_CATEGORY:

ITEM_INSPECTEDITEM_DESCRIPTIONITEM_CATEGORY
2Roofs, flashing, ventsExterior Items Inspected


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>