I have a hierarchical database out of which I would like to return all components in an asset with a specific common parent component. Components in table astComponents are linked to their parent …
Tag: sql
Delete Result Rows from a Table in SQL
I have 2 tables named BM_Data1 & BM_Data1_May62019. Both Tables contains the same data as BM_Data1_May62019 is the copy of BM_Data1 table. But BM_Data1 has some extra rows, How can I delete those …
rails multiple has_many relationships between the same models
I’m trying to figure out the best way to model a many-to-one relationship in rails where there are multiple scopes to the relationship. An example would be a restaurant has-many photos. I want to be …
How do you select all rows when data occurs in one of the rows?
I have a table with data |FormID|Name| 1 A 1 B 2 A 2 C 3 B 3 C I am trying to query all rows where Name ‘A’ appears, …
SQL query to interpolate between values
I intend to interpolate (linear interpolation) between values in a column and insert that into a new column using a SQL query. Based on my search online, I suspect LEAD analytic function could be useful. I am new to writing SQL queries. So, any insights on how it can be achieved will be quite helpful. The sam…
Aggregate data from multiple rows to one and then nest the data
I’m relatively new to scala and spark programming. I have a use case where I need to groupby data based on certain columns and have a count of a certain column (using pivot) and then finally I need …
How to remove rest of the rows with the same ID starting from the first duplicate?
I have the following structure for the table DataTable: every column is of the datatype int, RowID is an identity column and the primary key. LinkID is a foreign key and links to rows of an other …
How to create a query to get the multiple row data in comma separated format in one row in Oracle
I have a requirement where I have column ‘NOTECODE’ in database table POLICY which contains multiple Note Codes in comma separated format. Ex: CC,TD,HL POLICY : POLICYNO | NOTECODE ———-|—-…
Arithmetic addition to aggregate function
I’m new to sql and wanted to perform a simple task using aggregate function in sql. select (current_data + avg(current_data)) as “average + current data” from datasets However, arithmetic addition …
How To Extract Distinct ID’s Present In One Table But Not Another
I have two tables, one with the sales entries (multiple of the same salesman id number), and another that is a master file of sales people (only one salesman id per each salesman). How can I write a …