Database view not limiting results

gjz
Mega Sage

I've created a simple view for reporting use in our data warehouse on the Hardware (alm_hardware) table.  Only assets that are "In Use" should be in the view, but it's not limiting the assets and I can't figure out why (we aren't using life cycle yet).  Can someone help me understand why the where clause isn't working?  The view currently only has one table in it - Hardware.  TIA!

 

View:

gjz_0-1692723859363.png

 

Results when clicking "Try it":

gjz_1-1692724016531.png

 

7 REPLIES 7

Brad Bowman
Kilo Patron
Kilo Patron

Database views must consist of two or more tables joined together by a common field.  You can self-join the hardware table and limit the records to only those in use like this:

BradBowman_0-1692732258158.png

Where clause on h2:

h1_sys_id=h2_sys_id&&h1_install_status=1

 

They don't have to consist of multiple tables as I am able to use a single table to verify the fields and data that I want in my view.  I do still have three more tables to join.

 

This isn't SQL.  If you're going to use the ServiceNow defined Database View functionality, then you have to follow the parameters by which it was designed to operate.

https://docs.servicenow.com/bundle/vancouver-application-development/page/use/reporting/task/c_Creat... 

 

As demonstrated, my response clearly addressed your stated question.  When asking for help from others, state your actual question for your use case.

Mr Anderson
Tera Expert

It's only when you're connecting columns between tables that you need the single =, if you're using a boolean return value for filtering like you are here you'll need ==, as shown in my screenshots.  I used the OOB incident_sla database view and filtered it so that only Incidents with a state of 'New' are returned.

MrAnderson_1-1692732348519.png

 


MrAnderson_0-1692732291548.png