Can we create custom views with sql - i want to write a little bit different sql
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2023 11:15 PM
Hello,
I wanted to write custom SQLs which are not simple joins. This SQL will be join of pm_project and another custom table. I need to do union ALL with multiple sqls. Is there a way where i can write such SQL views (the way we would in a standard SQL database) ?
What i need to do is to transpose few rows of the custom table into columns and then join with pm_project to have this view.
#SPM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 06:21 AM
The way you do that in Servicenow is using Database Views. There is no direct SQL access to the database. There was a long time ago, caused too many problems as customers would cause data loss and other problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 01:41 AM
Hello Bert,
Even with views, I am trying to find sysparams where i can filter by column value = year - from sysdate.I could not find how to achieve this. I would want to have views for 10 years (one for each year) starting with year of sysdate. I could not find a way to do it. Each year, the views will slide to next 10 years.
Best Regards,
Ashwini Pingle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 07:20 AM
Hi,
See:
And the methods 'getYear()', 'getYearLocalTime()', 'getYearUTC'.
to determine the year from a GlideDateTime field.
As far as querying a table's DateTime field for specific year values, I believe that will require script logic. Build start and end values as yearValue+"-01-01 00:00:00" and yearValue+"-12-31 23:59:59".
Maybe other Community members have a better approach.