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…
Tag: sql
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
My last upload of data, the timestamp is off by 2 days, how can I fix it?
So I have a table in Snowflake that I uploaded and made the mistake of uploading some data with the incorrect datetime. The first few columns of the table are different json results, that correspond to the date they were fetched. Example: The INSERT was pretty straight forward, I staged the file and inserted …
How can I concat 2 different numbers to look like a decimal but is actually a varchar without losing place in the decimal portion?
I’m trying to calculate Hours and Minutes, but the minutes portion is dropping the leading 0 and it appears the calculation is incorrect. Example, 9.06 is displaying as 9.6 using this query against the values ClockIn 2020-01-07 23:00:53.000 ClockOut 2020-01-08 07:06:52.000 This results in a calculated t…
SQL Query “like” operator error, when the field is null
this query returns 421 records: Now when I implement the “like” operator, it returns 349 records, it is not taking into account the records with the field “invoice_number” in null:
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
SQL append data to table using dense_rank()
I’ve been trying to piece together bits of code that I’ve googled but haven’t had any luck. I’m trying to add a new column to an existing table. I can view the column using the below code from a select query: I basically want to append the results from this select query to my original …