Skip to content

Tag: sql

How to get percentage based on columns

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…

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…

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…