I know there are a lot of references out there for what I am going to mention. I am rather sharing something I feel should be very useful and consolidating in one place – Q&A-style. I have struggled earlier finding this for different constraints on different time. The following constraints are commo…
Tag: sql
Can I have SQL incrementally count XML elements while parsing?
So this is my first foray into parsing XML, and I’m trying to figure out how to get this to work how I want. Given the following XML format: I want it to put it in a SQL table as the following: Basically, imagine a grid, and each “TileRow” starts a new Row in that grid. Each “TileValue…
Variable to replace %s for sql is not getting honored
I have a table with single empty row inserted. Later I want to update column with some value into the row. I am trying to compose a function which will work for all the columns as shown upon execution update_column(‘fieldName’, 10), getting following error. Any help is appreciated. Failed to execu…
get unique record counts of two joined tables
I have a three tables: topics, sentences, and vocabulary. Sentences and vocabulary both have a belongsTo topic_id, but not all topics necessarily have both vocabulary and sentences. I want to get a count of all topics that have both sentences and vocabulary. I have it working if I do one table at a time: The …
iText PDF: the document has no pages
I’m trying to do a date range based filter to export a report into a PDF; however, when I click to export the PDF, I get the following message: ExceptionConverter: java.io.IOException: The document has no pages. Here’s my PDF class’ code: And here’s the code of the PDF generation butto…
Unable to grant all privileges to new user on Postgres
I’m creating a new user in a Postgres database (AWS RDS) and trying to grant all privileges on all tables in public schema of an existing database to that user. It is failing with below error. I even tried after logging in as the rds_superuser (postgres) and got the same error. psql (13.3, server 10.15)…
How to select a foreign key after narrowing down via Group By and Having in a subquery
I’ve got a unique problem. I’m querying a replicated database table cost_plan_breakdown, and the replication is known to have some duplicates due to issues with deleting records. I’m not the Admin so I’m trying to sidestep these duplicates as efficiently as possible. The table looks li…
Oracle sql query to group two sets of dates if sequencials
I have the next table: EMPLOYEE CODE START_DATE END_DATE 02097368 F7H3 09/07/2018 20/10/2018 02097368 F7H3 21/10/2018 05/01/2019 02097368 F7H3 06/01/2019 12/01/2019 02097368 F7H3 13/01/2019 02/02/…
Iterate an array using only select query in teradata
I’m trying to achieve the output table using the input table. The input table contains id and name where id has the numerical values and name contains JSON value. I can get the output by writing a …
Can we concat as well as replace string values in SQL Server (SSMS)?
I executed below query, but I got result as null values. Instead I want my output to be: Answer The more recent versions of SQL Server support concat_ws(): In older versions, you can use: