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
Giga Sage
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 ...
9 REPLIES 9

Ankur Bawiskar
Tera Patron
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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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 G- LNG
Tera Patron
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

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************