For a pair of dates (date1, date2) = (Fri 2021-01-01, Wed 2020-01-01) I need to extract the day of week from date1 (Friday in this case) then find the nearest Friday (or whatever) for date2. The result for the above pair would be Fri 2020-01-03 (2 days after that Wednesday) and not Fri 2019-12-27 (5 days befo…
How appropriate is one column table
Does this kind of design come along with overhead or data redundancy? The structure of tables should remain able to do CRUD on tag, for something like manga/anime tag, allowing specific resources found-able through selection of tags. * representing primary key. Answer There is nothing at all wrong with your d…
MySQL Workbench – SELECT is not valid at this position with this server version when using CASE WHEN statement [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 11 months ago. Improve this question When implementing a basic CASE WHEN statement in MySQL Workbench, I…
Call tabled function with parameters in sql
I’m a newbie in SQL and with programming languages in general. I’m trying to make a tabled function in SQL (SQL Server): and then I have to call it in another sql page. I’ve tried to use this syntax: If I run my SELECT I don’t have any result, because my parameters are not initialized.…
Why is my SQL query executing indefinitely?
It seems that this code is correct and I am not sure why it is not executing. I thought it might be extremely inefficient but after 15 minutes it is still executing. edit: Thank you all for the input. Answer You are using implicit CROSS JOIN in your query and this can kill your performance if you don’t …
How to extract everything after parentheses in BigQuery?
How can I extract all the characters after the first word? For example, I would like to have (084M) in its own column with the parentheses included. I’ve tried to SPLIT and REGEXP_EXTRACT but I have ran into issues. Table: Name Elizabeth (084M) Elizabeth (084M) Elizabeth (084M) Pittston (14KN) Pittston …
trim function not working on result of to_char
The query gives the result 3 as expected but the query: gives 003 I need the result to be as the first query (‘3’) but I also need the ‘TO_CHAR’ (I’m using it to create a virtual column from a NUMBER column). I can not figure why and how to fix it. Also, I can not use regex_repla…
Use a macro in SAS ‘to_date’ conversion
Being forced to pass my code in explicit pass though, the date conversion no longer works. I would like to use the &aaaa macro in the convert function. My code example : I got an error : “The (full) year must be between -4713 and +9999 and be different from 0”. Does anyone have a solution? Ans…
Query to Identify Above Average Sales for Company
I am trying to find the employees who have sales figures that are above the average sales totals for a particular company. I am using Microsoft SQL Server, and here is what I have so far: However, my query returns nothing. Is this the correct way to write something like this? What could I do to simplify thing…
Linq Find the most recurring record
I have a rent a car project. This is the table where I keep the rented vehicles I want to find the most rented vehicle in this table. How can I do this? So I want to find the most mentioned car Id in the table [I have to do it with context architecture. How can I do this with