Let’s consider a toy example. There is a table employees and table tasks, where each task is assigned to one employee. One employee can have multiple tasks. I want to query employees filtering them by some columns in their tasks. I group the employees to display each one only once. The query would be so…
Tag: sql
Error in sql syntax value ? but it’s showing the value?
the title isn’t very specific but I don’t know how to make it better. I’ve got this error in my sql telling me something is wrong but I don’t understand why it’s wrong, currently using mysql 8.0.24. If you wonder why it looks strange it’s because I use it in lua Sql: Error:…
Assign unique id each time two fields/columns are an exact match
Big Query: I’m looking to assign a ‘unique combination id’ if a person and date are an exact match. So for each specific time a ‘person_id’ and a specific datetime are the same, they are assigned a number overall (time will always be 00:00:00 but just has to be there for records)…
SQL Oracle: Save variable from select with where statement
i’m using SQL Developer 19.1. I have a huge script with multiple subselect statements. It looks like this i want to get var1 and var2 with a another select statements. How do i do that? i tried but it seems like i cant use a where statement there. i also tried something with bind or @var1.. Do you guys …
SQL Oracle: add column from other table twice but with reference to different tables
I have 3 tables. One of those tables has a key (unique Number) and out of this table I need a column (“Number-Text”) to to be added twice in my output table. Table1: BelNo Plant ProductNo 123 A 999 234 A 888 345 B 989 456 A 999 Table2: BelNo MaterialNo 123 001 234 002 345 001 Table3 (with unique
How to find similar string value in Bigquery
I have two tables in my database, each table has column with names. How to compare these tables columns and how to find these names what has exact matches and these names, which are similar in table1 and table2? For example : Table 1 Table 2 : Result should come out with this: Table 1 –> Table 2 how …
Correct use of a LATERAL FROM
I am trying to use PostGIS to undertake a number of steps within an SQL statement to basically convert a raster to points, buffer, dissolve and then determine the overall boundary i.e. concave hull based on an attribute. The following is where I am at but get an error suggesting the use of a LATERAL FROM but …
Delete the row with the highest date difference
I have a table with values I would like to delete the row with the oldest student. I am able to get the ages with the following command but somehow I cant combine it with the DELETE stament I am using SQL lite Answer This would remove the first of the MAX result if there are some with the same
Sort by one variable, group by another, and select first row in SQL Query in R
I need to apply a procedure in SQL that is easy for me since R, but has been really tortuous in SQL. I need to sort the data from highest to lowest by two variables, group based on another variable, and select the first item in each group. I leave the code that I am trying to pass from R
How to remove subtotals from groupby OLAP Cube?
output The filter shows field is not null. Why am I getting a Field NULL as part the EmployeeCount output when using cube? I figured it out. Cube includes subtotal and totals where the column is null Is there an easy way to remove the rollup values in the cube results Answer use group by grouping sets, it all…