Skip to content

Tag: sql

SQL Use column value in another column

What I’m trying to do is best described as mad-libs within SQL where there is one column that acts like a “template” that will end with all the values from the other columns inserted into the correct position. An example of what a sample table might look like is below. The final query should…

Use a subquery and a custom value with IN operator

I can’t really find any answer that fits my question. I need to know how I can be able to use a subquery together with a custom value with the IN Operator in SQL. Here is an example of a query I came up with: This query is meant to show posts only from users in a users’ following table

UPDATE based on multiple overlapping conditions

I have a query which essentially transfers a job from one worker to another. The query works fine, but I need to add one additional check: ensure the current job owner (in jobs) is the worker matching @owner and @teamId. This is essentially the condition that I need to add: To the query below: The problem is …

How restart the incremenal from a temp table in SQL

I want to try to do an incremental number for a table, that has to return to 0 when seeing from the previous column (LAG) 0. This is what I tried to do: And this is what I am expecting to get out: I’m not familiar with the WITH common_table_expression is the right way to solve my problem? Answer You

Customers who’ve ordered one time in the past three years

I’m attempting to retrieve a list of customers who have ordered one time in the past three years. I thought that “HAVING COUNT(INVOICE.INVOICE_NO)=1” would get me there, but I’m still getting multiple invoices from the same customers, so I know they’ve ordered more than once. Tha…

Where can I find MySQL Path/URL for NetBeans?

I’m trying to do school JAVA EE project and I have to connect schema made in mysql from MYSql. part of code is (for SQL select) : and i apperently have no URL somehow Any ideas on that? I’m new to SQL and JAVA EE so i face lots of problems :/ Answer First of all you need a running