Database View Syntax for where clause

dlrich
Kilo Contributor

I want to filter a database view so that the output is only certain values in the view.   For example, on the task table, I want task to be of certain task type or certain states (tsk_sys_class_name = 'sc_request' AND tsk_state = '1')
but nothing I do seems to work.

10 REPLIES 10

This interesting, I am doing it for application table to get non-retired applications. can you check if I am doing it right or not?

I am receiving nothing in the DB view.

find_real_file.png

Thijs vL
ServiceNow Employee
ServiceNow Employee

http://wiki.servicenow.com/index.php?title=Database_Views



A typical view works best on the platform when the where clause only links references together with the purpose to join tables (TableA_sys_id = TableB_sys_id) but does not contain filters (active=true), those can be applied after the view has already done its join.



So make the join, hit "Try It", then apply your filters.


Joe72
Tera Contributor

Which would work great if the export of the filtered view didn't have blank rows in it! 😕

ex: database_table_name.do?EXCEL&sysparm_query=encoded_query

Shows the correct data, but includes blank rows for the rows that were filtered out

gputker
Tera Contributor

I got this working on a choice (TRUE/FALSE) field:


(cirel_child=eaapps_sys_id || cirel_parent=eaapps_sys_id) && eaapps_u_critical_application=1

The text in black joins two of the same tables with an OR condition.  The text in red returns only TRUE values for the critical application field.

Took a lot of tries - I'm rapt.

niharika2123
Tera Contributor

How do we create a view such that there are all the records of Table A and the records that link with Table A and B.

 

So, we have few cases and HR audit tasks(custom table) - both extended from the task table.

I need to report on both HR audit tasks which have HR cases and The Hr cases which do not have HR audit tasks. Unable to resolve this.

 

Thanks in Advance