So I have a database of pipes that is visually coded in qgis. My goal is to add a trigger to PGAdmin4 v5 that uses ST_StartPoint() and ST_EndPoint() to get the end points of the polyline (the pipe) as it is being entered. Then, I was going use this geometry to grab the nearest structure (a point) and autocomp…
Tag: sql
Oracle sql – get months id between two dates
I have date range eg. ‘2021-01-05’ and ‘2021-02-10’. Two months January and February. Need resaults: Answer You want to iterate through the months. This is done with a recursive query in SQL:
How to only display current and valid data from 2 tables in sql
I have these two tables: Table imp_source: Table imp_update: I need to write a query to have this result: All values of imp_update The values of imp_source when there is no update for seq column of a product/class combination. Update 1: As you can see, the row in imp_source is not in result Because in imp_upd…
Laravel 8 Livewire search filter not working with first where clause
I want to have a table which shows all the data per company that has a filter search input, the problem is when I put the first argument where(‘company_id’, Auth::user()->company_id) it bugs out and doesn’t make the filter search work. This is my query for the table. Answer I suppose you …
How to select whether or not a specific date is before X amount of years? – Presto SQL
I’m trying to select whether or not the date value in one of my columns takes place before a certain amount of years. The code I’m trying out: My expected output should be NULL for the dates I’m using (e.g. 2019-09-30) as they fall within the last 10 years, but for some reason, I’m get…
Redshift sql identify records based on timestamp which came before a certain record
I’ve a redshift table which has the following structure I’m trying to find 3 sets, all titleIds [preferably entire row, not just the list of titleIds] which have country IN after US, the other way around which have US after IN and all titles which just has an IN entry and nothing else. Now its pos…
Compare 2 time datatype
I have a table in SQL Server which has 2 columns StartTime AND EndTime. The datatype of both columns in time(7). So when I view data in the table it can look like this: 08:33:00.0000000 or 19:33:00.0000000 I want to return all the rows in the table where StartTime and EndTime conflicts with another row. Examp…
Return first available row if initial SELECT finds nothing, in a single statement
I am trying to put together a SQL query that will return data based on a simple WHERE condition but will also return the first available record if the condition is not met. author_id post_id publish_date 1 31 2021-07-23 2 432 2021-06-22 2 555 2020-07-23 Using the data above my basic query would look like this…
MYSQL joins and then making queries on the joined table
I am trying to do a join on a database and subsequent queries, in this database which is a dummy one from MYSQL y hace these tables and in the salaries table i have something like these So I am trying to sum the salary and group the result by employee number so I have just one value per number,
Unable to assign value to variable with convert
If i make it like that it returns me a 10 digit number, but if i try it like that it returns only 1 digit.Why,isn’t it the same thing? Answer In this line: The length is not being specified. The default length is 30, and char will pad the rest of the length with spaces. So @ID is already filled,