I have a table that has a bunch of columns, one of which is a ‘last_update_time’ column. Whenever I change the value of any of the other columns, I would like ‘last_update_time’ to automatically update to SYSDATE. I know that you would usually use triggers for this kind of thing, but a…
How do I find first value in every last 3 months in Hive
I have a table like below. I need to get the first Refresh_value (based on Refresh_date) from last 3 months starting from the last date and there should be 2 additional columns (Group and Refresh_Value_Min) where 1st column will have the first value from every last 3 months and another column will have values…
how to get a record based on max date for each user in different multiple tables
I’m trying to make a query that can select the names, DateOfSpecimenResult,SwabResult,DateOfReleaseOfResult. Heres the Visual Representation: Table: ContactTracingHeader Table: Swab Note: ContactTracingHeader.AutoID = Swab.PatientNo Table: SwabResult Query Output that I’m trying to make Note: Swab…
Run a query based on the values returned by another query
Consider the tables: If I were to run query1: I want a query that would return all of the rows for open work orders in that date range (i.e. include the process, run, and ship). This would be the equivalent to what I want returned: Therefore the desired output would be: But I don’t want to specify each …
Group by sub-string while selecting the full string
Let’s say my sql dataset looks like this and it has one column: John John,2345 Joe,1234 Joe Joe,1234 John John,2345 John,2345 Smith Smith I am going to count the number of times …
Where should I modify?
This is an oracle sql. SQL servel says “there is no USERS Table” but user table exists in my db. Answer You don’t need the table name.
Truncate if exists in psql function and call function
I have the following code to create a function that truncates all rows from the table web_channel2 if the table is not empty: create or replace function truncate_if_exists(tablename text) returns void …
SQL GroupBy for Stored Procedure caused Error
I have a quick question that why my SQL Stored Procedure did not work properly. Can someone explain what is wrong with my Stored Procedure Query? Error: “Each GROUP BY expression must contain at least one column that is not an outer reference.” Answer It can never work the way you are trying it, b…
SQL aggregate function on result of another aggregate function
Short backstory for this question. I am a student who works part-time as a tutor for several classes, including an entry level SQL class. I’ve got a student who has a fairly complicated database, compared to what most people get out of this class. Since their database ins’t super simple, they̵…
Dummy Column in SQL Query
I am working on a SQL query and I need to do a calculation and store the result in dummy column in the output. I am doing the calculation as shown above however I am still missing something. Any help will be greatly appreciated. Answer SQL doesn’t allow for you to do computation on data being computed i…