so here is what I have: I have a hired column which is boolean values, population which is either US or EU values. Right now the freq divides the hired over the entire population which is like 5,000 values but I would like it to divide which are specifically US or EU values. Can anyone help me with doing this…
Tag: sql
Hive regexp_extract numeric value from a string
I have a table as: I am trying to get the numeric values from the table. The expected output is A -> 123 / B -> 124 etc I am trying to do using regexp_extract Any suggestions please? Answer If the delimiters are fixed – ‘; ‘ between key-value pairs and ‘=’ between key and v…
How to add a new column in a view?
I have this view: And I wanted to add a new column with the following replication code: but he returns the error: I thought about deleting this table that already exists, but I don’t know if it would be the best way to do it. How can I do it? Answer you can use alter view. Its better because it
Find a value from table that is only unique to one id
I have a table “stats” that consists 3 ids. IDs: id_seller, id_part and id_proj From this table, I want to find projects (id_proj) which buy specific parts (id_part) that is avaiable only from one seller. In other words: Find id_proj, which buy id_parts, which are avaiable only from one seller (se…
How to find ‘MAIN’ master record SQL
I’m running a query: Which returns the following results: I just so happen to know these IDs and am using them for this example. How can I return results like this across the board grouping together linked companies, until I get to the ‘MAIN’ company. There are going to be several other comp…
Change the text color of a shuttle based on a condition in oracle apex
I have two different tables in oracle apex, the first one is the documentation table which contains KPI’s, the second one is the results table which contains all the KPI’s results. I have created a shuttle in a page to choose KPI’s from documentation table then, insert the results into the r…
Suggested way to do a ‘parallel period’ SQL statement
Let’s say I want to get the profit between two dates. Then I can do something like this: I would then like to compare it to a previous period offset by a fixed amount. It could be written something like this to get it in two rows: Is there a way to do this without a union? I am looking
How can I parameterize an SQL table without vulnerability to SQL injection
I’m writing a C# class library in which one of the features is the ability to create an empty data table that matches the schema of any existing table. For example, this: The above code works, but it has a glaring security vulnerability: SQL injection. My first instinct is to parameterize the query like…
SQL: placement of inner joins and impact of performance and correctness
Is there any difference ( in performance and correctness) between these to SQL (sqls are not important) SQL no. 1 SQL no. 2 also, table a has 500 000 records, table b has 1000 000 and table c has 1 5000 00 records Answer Honestly I don’t think reversing the join statements will make much of a difference…
Decreasing Cumulative Sum That When Equal to or Less Than Zero Change Another Value
Below we have two tables, one of purchase orders and the other of sales orders. What I’m trying to do is assign each sales order to a purchase order, with free stock. Which I can do with the following query: Table 1 – Incoming Purchase Orders: number item shipDate qty usedQty freeQty 12 Toy 2021-1…