How to write a "where clause" in a database view

vishnumaaya
Tera Contributor

Hi, 

 

1. After creating a database view , adding the tables you want to combine , how to define where clause?

2. How do we know which one to write where clause for??

3. For example, see the picture below,

vishnumaaya_0-1740660780885.jpeg

- How to judge where to write the Where clause? as in where clause is written near the change_request and not task_sla 

- Why was it written in change request where clause?

- Why did it not use change_request_sla table n used task_sla table??

 

Please share any article, blog or videos if you have. 

 

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

Viraj Hudlikar
Tera Sage
In this ServiceNow Tutorial, Aaron Elder gives a demo on creating and using a database view in ServiceNow. Create the database view. Role required: admin. Learn more: https://docs.servicenow.com/bundle/paris-platform-administration/page/use/reporting/task/t_CreateADatabaseView.html ...
This Video explains how to develop a Servicenow Database View.
Hi Folks, In this tutorial we will be focusing on 3 aspect wrt Servicenow Database view What is ServiceNow Database View ? How to Create ServiceNow Database View ? How to Use ServiceNow Database View ? Lets understand the The value of ServiceNow database views ServiceNow is built to be dependent ...
Hi Folks, In this tutorial we will be focusing on 3 aspect wrt Servicenow Database view What is ServiceNow Database View ? How to Create ServiceNow Database View ? How to Use ServiceNow Database View ? Lets understand the The value of ServiceNow database views ServiceNow is built to be dependent ...
9 REPLIES 9

Ankur Bawiskar
Tera Patron

@vishnumaaya 

Explanation here:

1) row 1 is for change_request, it should be with 100 order

2) row 2 is for task_sla, it should have where clause and should be with 200 order

You can write where clause in any row but ensure it's correct with correct prefix

- Why did it not use change_request_sla table n used task_sla table?? -> this might be as per customer requirement as SLAs are stored in task_sla table

If my response helped please mark it correct and close the thread so that it benefits future readers.

@vishnumaaya 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Hi ,

 

This is not created by the client but OOB one, I just selected this as an example only!

why is order important in database view?

 

Thanks,

Vaishnavi

Dr Atul - LNG
Tera Patron

Hi @vishnumaaya 

 

- How to judge where to write the Where clause? as in where clause is written near the change_request and not task_sla 

Atul: it is mainly on main table like where is main record exists.

-

- Why did it not use change_request_sla table n used task_sla table??

Atul: The Sla stored in task_sla table and i.e. reason we use task_sla.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0719186