Jump to content

Recommended Posts

Posted

This is probably a long shot, but I'd really like the ability to coalesce columns in a report.

In a specific use case, I am generating a report for computer, computer peripheral and mobile device assets, and have a need to include the manufacturer, model and serial numbers for each asset type.

Currently, this generates a report with 6 columns: 3 for each type of asset.

Using direct SQL, I can run the following query using the COALESCE() function to combine these 6 columns into 3, however I would like to be able to achieve something similar in a report.

SELECT h_asset_tag,
    COALESCE(ac.h_manufacturer, acp.h_manufacturer, amd.h_manufacturer) AS h_manufacturer,
    COALESCE(ac.h_model, acp.h_model, amd.h_model) AS h_model,
    COALESCE(ac.h_serial_number, acp.h_serial_number, amd.h_serial_number) AS h_serial_number
FROM h_cmdb_assets a
LEFT JOIN h_cmdb_assets_computer ac ON ac.h_pk_asset_id = a.h_pk_asset_id
LEFT JOIN h_cmdb_assets_computer_peripheral acp ON acp.h_pk_asset_id = a.h_pk_asset_id
LEFT JOIN h_cmdb_assets_mobile_device amd ON amd.h_pk_asset_id = a.h_pk_asset_id

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...