Skip to content

Specify a specific year to be updated

I’m dealing with an old database that contains records of 365 days of the past 3 years. I’m trying to get the 2016 records ‘for example’ and change the year to 2020 and then add my new record to the table so it would contain now records of 4 years. this is what I did so far : I want

ORDER BY num-rows of another table

I have to create a ranking of the directors who have made the most reviews. What is the method for reordering according to the number of rows in another table? Table 1 (director) Table 2 (employee_reviews) Result (Directors ranking): Answer You need to join to your table and select the count when (ON) the aut…

how to join with IIF function?

Hi I am using MSSQL 2017 and try to figure out how this code works DECLARE @customer TABLE ( credithold bit, id int primary key, deliverycityID int, postalcityID int ) DECLARE @city …

Redshift – Missing latest date when join two tables

I have two tables (Calling as A and B table); Table – A data only includes the last 1 month data. Table – B data stores all data that you have. I need to find the difference between these two tables dates, but when I left joined the two tables I have null dates: I am going to use last_value

Subqueries on same table

What I want to do is run a subquery from the same table in a single query my SQL is below: SELECT DATEPART(DAY, dateTimeCreated) AS DateClicked, COUNT(*) AS NumClicks FROM […