The CreatorCon Call for Content is officially open! Get started here.

Combining Tables

sapnasarkar
Tera Contributor

I have two table i have common keys As Cloud in both the table but they are not primary key. How can i combine them. Is there any other way to combine to combine them.

 

17 REPLIES 17

hi @sapnasarkar ,

 

A database view defines table joins for reporting purposes for more information refer  Database view 

Database View with Multlple tables tutorial 

 

Thanks,

BK

Hi @sapnasarkar 

 

For reporting purpose you can use the Database view and then use that datbase view in report.

https://youtu.be/sejye-DCjok

 

*************************************************************************************************************
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]

****************************************************************************************************************
CISITSM #ITSM #csa #ServiceNow #TechnoFuncational Disclaimer: These videos are from my training batch. These videos did not promote any ServiceNow Sales pitch or marketing. These videos are only for knowledge purposes & basic on my experience & Knowledge. Redistribution or copying of functionality

PrabhakarCh
Tera Contributor

@sapnasarkar 

looks like you want to combine tables for reports or to create virtual table.

Check this solution to combine two tables with common keys using Database Views. This will allow you to create a virtual table by joining multiple tables based on a common field, even if it’s not a primary key.

  1. Create a Database View:

    • Navigate to System Definition > Database Views.
    • Click on New to create a new database view.
    • Define the name and label for your view.
  2. Add Tables to the View:

    • In the Database View form, add the tables you want to join.
    • Specify the join conditions based on your common key (e.g., the “Cloud” field).
  3. Define the Join Conditions:

    • Use the Condition Builder to specify how the tables should be joined.
    • For example, you can join Table A and Table B where TableA.Cloud = TableB.Cloud.
  4. Save and Test the View:

    • Save the database view and test it by querying the view to ensure it returns the expected results.

If you like my response, please click on 'Helpful'. 

Best,

PC

Table                                                                                               ...Order VariableprefixWhere clause

 u_hcm_finops_gcp_forecast u_hcm_finops_gcp_forecast100gcp forecast 
 u_hcm_finops_gcp_daily_usage u_hcm_finops_gcp_daily_usage200gcp daily usagegcp forecast.Cloud = gcp daily usage.Cloud
 u_hcm_finops_azure_forecast u_hcm_finops_azure_forecast300azure forecastgcp daily usage.Cloud = azure forecast.C...
 u_hcm_finops_azure_daily_usage u_hcm_finops_azure_daily_usage400azure daily usageazure forecast.Cloud = azure daily usage...
 u_hcm_finops_aws_forecast u_hcm_finops_aws_forecast500aws forecastazure daily usage.Cloud = aws forecast.C...
 u_hcm_finops_aws_daily_usage u_hcm_finops_aws_daily_usage600aws daily forecastaws forecast.Cloud = aws daily usage.Cloud

this is not working