We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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

It turns out a single = works, I just didn't work until I joined my second table, then it worked.  I'm not sure why that matters, but it fixed the issue.

AndersBGS
Tera Patron

Hi @gjz ,

 

why creating a database view when you’re not joining two tables?why not just create a basic report according to your needs?

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi AndersBGS,

 

I am joining four tables in the view, but I always add them one at a time and validate I'm getting the data that I expect.  Since I knew I only wanted assets that are "In use" I didn't want the entire asset table of data when I only needed a subset, which is why I applied a filter in the where clause and was surprised it didn't work.  I come from a SQL/Oracle database background and am used to much more robust scripting than ServiceNow's database views allow.  As I noted, once I added the second table the filter did apply - which doesn't make sense to me, but that's how it worked.

 

And for your second question, the view is for a REST API to load the data into a data warehouse where much more robust reporting is available.