I try to get the top 3 length per film for each actor. My query looks my this. SELECT fullname, ROW_NUMBER() OVER (PARTITION BY fullname ORDER BY length DESC) as f_rank, length FROM (…
Tag: where-clause
MySQL query to sum one column and count another column, from two tables, based on a common value?
I’m having issues getting my head around a query that I am trying to build. I’m hoping for a bit of help here… I have two tables. Each table has two columns. They are described as follows: Table: “Token” Table: “Score” I want a query that will list each name once, and with each name the sum of Points for
setting time range in SQL Developer
I am working on a dataset that contains car accidents and their time of occurrence. (the data set exists in SQL Server under the name accident). I have a column that is in date format. I would like to extract the time from the column. Then add a new column called lightining_period label the time as daytime or nighttime. My
tweaking stored proc
I have a stored proc that gets called with a parameter. I would like to check what the PARAM @Value is, and depending on the value, I want to add a part of a WHERE clause if it equals to a certain value. Let’s say the proc looks like this: This is a much simpliefied code, my WHERE clause for
Oracle filtering with multiple Exists but only one can evaluate
Please consider this pseudo-query: Consider that: “From A” is much more complex and I don’t want to do more joins there. I’m filtering results and foreach record A i just want to return a single row, that’s why I have the exists in the order i want them to evaluate; How can I avoid running the 2nd exists (due to
Comapring DATE_ADD with NOW not working on MySQL
I’ve try to compare an DateTime in MySQL. The table is to check locked users. For sample, an User will be locked for 1 Day at the DateTime 2020-04-09 14:51:32: until is the datetime time_created with added days from locked_time. Here is the Result of entries: The calculation (time_created with added locked_time with the result 2020-04-10 14:51:32) is correctly. But
SQL select records with current month
I have a field name textbook date field name NewMonth The data like this My goal to select the records with current month (2020-04-XX) My query and not working. Can some one correct my query. Thank you I think -1 for current month, -2 for last 2 months , -3 for last 3 months andso on Answer My goal to
Query to get all companies that have products with all specified attributes
Let’s say I have two tables (1 to many): table company with fk id and table product with fk id and also fields sId and tId (if sId has data tId is null and vice versa, not sure if it matters). I want …
Calculate time from begin date in SQL
I’m trying to tally up the number of unique ID accounts that are active for more than a year as well as include how long each one is active. The problem with the code I have is it’s not including …
Remove specific fields and show other fields in Mysql
I would like to ask for ways to solve this MySQL issue. Currently, I have this select query SELECT username, friend_username from friends WHERE (username = “apple” or friend_username = “apple”); …