Skip to content
Advertisement

retrieve rows based on parent relationship

This is the query: I am trying to get all the checklist items that have the same item_stock_id from the checklists that have the same ambulance_id. However, the query from above is not working, showing me this error: Below is the ChecklistItem model: And this is the Checklist model: Answer To constrain the eager load you need to specify the

How to deduct sold quantity from stock tables in MySQL

I have two mysql tables. The two tables with the sample data are as follows. By this I want to build up a update query. This should deduct the quantity of the items in the sales table from the stock table. If such a query can be created in mysql it should be updated in ascending order on the stock_id

How to know what the select query took time?

I have 4 queries and I want to compare the time between them, Is there any command to show the time taken for every query? Answer You have can use SHOW PROFILE Statement. Enable it by using: For example, I executed some queries as below:

BigQuery SQL Regex_extract repeated pattern

New to regexp, below is the sample query and our try as below union all select ‘https://www.this-is-pqrs.com/<some_text>/ab.abc.ef.gh.ij/123456.csv’ str union all select ‘https://www.this-is-pqrs.com/<some_text>/ab.abd.ef.gh.ij/123456.csv’ str union all select ‘https://www.this-is-abcd.com/<some_text>/ab.abc.ef.gh.ij/123456.csv’ str ) select REGEXP_EXTRACT(string_tbl.str, r”ab[^/]*”) from string_tbl; output we are getting: Required output: Answer Use below with output

How to show the average and use it like condition in the same query?

I am working with a data base and I need to show the people who are older than the age average in a city comparing their age against that average. My code shows the people who is older than the average….but I can’t show the average of all the people (it’s allways the same number) in each line. I need

Oracle: WITH-clause querying two tables

Using an Oracle database, I have two tables: I am supposed to find – using the WITH-clause – all the employees who currently work in the same department where they started to work (hire_date = start_date and same department_id). I easily got the right result using a JOIN in the subquery: (Right) OUTPUT: Unfortunately with the WITH-clause I am getting

Advertisement