How do i query a table with multiple conditions? This give me no error but, only run the first condition! exports.findAllLimit = (req, res) => { const titulo = req.query.titulo ; var condition =…
Is there a more concise version of the CASE WHEN foo.bar IS NULL THEN 0 ELSE 1 END paradigm?
The goal is simply to check whether a field is NULL or not, yielding a value of 1 when the field is not NULL, and 0 otherwise. I can’t use COALESCE here, because if the field isn’t NULL, I just want to return 1, not the value of the field. I have a gut feeling that there’s already a function
Filter out records that are not in this date format oracle
How do i filter records that can only be converted to date using to_date(’31-May-2019 00:00:00′, ‘DD-MON-YYYY HH24:MI:SS’) from the above sample query i am expecting results below how do i achieve this in oracle. Reason why i want to do this: i am receiving raw data and loading it to a…
Select columns based on condition in Snowflake
I am trying to find a solution to select columns in Snowflake based on a condition. For example I only want to select columns which contain the string “id” or only the numeric columns. Is …
How to select the 16 highest values out of 18 values SQL?
Ok so I have changed it from columns to rows instead 😉 Im saving grades for students. I have a MySQL table called “grade” with three columns called “subject”, “points” and “userId” with 18 rows with different subjects where each subject can have one of the value…
Find the longest rainless time (every hour, beyond several days)
I have a weather station where I measure the amount of rain per hour and save the data in a database. The rain-table looks like this: Now I want the longest rainless time per month. I already have a solution, but it only works for the respective day. However, if there is no rain for several days, my solution …
Add additional column to the query output
I have the following query that is grabbing data from a table and combining all the products into one column and counting the quantity of that order. I need to add an additional column to the output though, how can I also add ship_date? This is how the original table is laid out: And this is how the query out…
Get all tables data with Node.js and SQLite
Having these tables into a db: Athlete with fields: athlete_id, name, surname, date_of_birth, height, weight, bio, photo_id AthletePhoto with fields: photo_id, photo, mime_type AthleteResult with fields: athlete_id, gold, silver, bronze Game with fields: game_id, city, year The db model: The code so far can o…
Sql join in two tables and return empty tab as Unavaliable
In a SQL join, table 1 contains person info with city and table 2 contains city matched to country such as:- Table #1 Table #2 I want to get the person ID, Name, Country so while joining the tables I want these items and if there is no country available for a city, I want “Unavailable” written in …
Query to find people with multiple names
I’m working on a fairly big project that allows users of my client’s site to search for people they used to know who might’ve changed their names, primarily due to marriage. Basically, users sign up with all the names they’ve ever used and the data gets entered into a MySQL database. T…