Skip to content

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…

How compare dates that are equal when one has time as well

I’m trying to compare dates and it looks like I’m doing it like examples online, but I only see the rows of dates returned when I do >= for the comparison. When I just use = it doesn’t return anything. This is my query with >= for the date comparison: I see a lot of this sort of thing …

Find names based on max number dynamically in SQL

I have a data set like this: Table A: What’s the maximum number of Place on which a Partner has spent money and who are these Partners? Display only the Partners reaching this max number I tried this: But I feel like its not the right logic. What am I missing? Answer There’s really no need for you…