I’m trying to speed up a query that uses Contains Near with one that uses regexp_like. The initial Contains Near query takes about 45 minutes to run. Clob Column holds large “documents” and is …
Tag: sql
How can I specify column name casing in TypeORM migrations
I’m using typeORM and I want to use migrations instead of syncing because I’m working in a team and it’s actually a lot of tedious work to get the db to a state in which the app actually functions. …
group by JSON Column that contains an array
I have the following table: that contains these data: How can I group by my array items in my JSON Column? and get this result:
How to pass a php variable in WHERE clause of SELECT statement?
I have a php variable that I want to fetch another field in database using this variable in my where clause. My code: But this is printing me nothing. Don’t know where I am going wrong but any help would be appreciated. Answer You can either break the string and concatenate the variable with “..&#…
knex postgres join as nested JSON
I’m using knex with postgresql db, I have a row in table A which has one-to-one relation to rows in table B and one-to-many relation to rows in table C. I wanna join a row from A with B and C and get a json like Where stuff like aCol means column from table A, bCol – column from table
Running total in Access Query based on item and date
I’m struggling with an Access Query trying to create a calculated field which presents a running total of parts that have gone or returned in the store; sorted in the order of date in one table. The table “DMPartsT” would look like below: The result I am aiming for is for the query to return…
WordPress delete posts not in specific categories using wpdb query
How do I modify the following query to delete all posts with the custom post type “listings” that are NOT IN specific WordPress categories? Note, I must use $wpdb->query() in my particular situation. My categories for exclusion are term ID’s 21, 22, and 24. UPDATE – THIS query bring…
SQL: Give the names of employees who earn more than their manager
Hi guys, I have this type of table, and I need to show the employees who earn more than there managers? It would be easier if we had 2 tables, but I cannot imagine a code within one table. Any ideas? Answer You can do “self-join” between the two tables. In the second table, EMPNO will be equal to …
Exclude weekends and public holiday for SQL datediff
this code works but seems like the results are off by 1 day Objective: Find the datediff for the two dates given. However, we will have to exclude Weekends Public Holiday Example The difference …
Explicitly distinguish similar queries in pg_stat_statements?
pg_stat_statements is (thankfully) pretty smart at normalizing queries to aggregate stats regardless of the arguments you pass. However, I’m facing a situation where a particular query is called from many locations across our application and I would like to get separate statistics based on these various…