I have below table name: CustomerContent with the below image data and My product is:is common in ProductContent cell. First colon no need to split (My product is:) if next colons we need to split the ProductContent Cell base text assign the values like below. If slip data content CGM then assign value 37. my…
Tag: sql
Use of ORDER BY returns column filled with NULL
I have to do the following exercise: Write a SQL query to list the names of all people who starred in a movie released in 2004, ordered by birth year. Your query should output a table with a single column for the name of each person. People with the same birth year may be listed in any order. No need
SQL – Inster into with now() minus one day
I want change this request. Actualy this request insert into always 2021-11-11 at 10:50:00 I use a script.sql for my H2 database (continous delivery). I want change my request to Now() minus one day at 10:50:00. Answer Subtract a day from the current date, then add the time.
MySQL JOINED table query should return zero but instead does not return those rows
I have two tables, saved_groups and user_comments and the second line of the query should (does, it works) return an extra column with the number of comments associated with each group. However, when a group has zero comments associated with it, that group is simply not returned. The only rows returned are th…
Check value of last 4 rows
I want to check the value of the last 4 rows from DB. If these 4 rows have a specific value, Do something. So the table looks like this: Here is a fiddle to test with: http://sqlfiddle.com/#!9/1064b3/1 I can run the following query SELECT * FROM testing ORDER BY id DESC LIMIT 4, Then check with PHP: Is there …
Using one query’s result into another
I have this query which shows the below result, I want to use this MarksObtained and take out min, max and avg of each course and show it with the second query (have provided below). This is the second query So it will basically show min, max and avg of each course achieved by the students. What I want: Sampl…
How to select records from a Postgres table using an ORDER BY statement on a jsonb column that points to another table
I have two tables, characteristics and students. characteristics students The characteristics table has three columns where the id column is an auto-increment field. The name denotes the name of a specific characteristic and the value indicates the respective information about the characteristic. The students…
SQL Error 3780 when using foreign key as primary key
I’m getting the following order trying to use a table’s primary key as another table’s primary key: ERROR 3780 (HY000): Referencing column ‘optimization_id’ and referenced column ‘optimization_id’ in foreign key constraint ‘optimization.main – optimization…
Adding time to a table in SQLplus without date
I am trying to create a table regarding telecommunication and I want to add time for 2 rows call_start_time and call_end_time and with that, I want to calculate the call_duration. This is what I used to enter the value If I use this format while displaying the data only the date is displayed not the time. Can…
I can not convert the data to the required form
Hi hi I have a Nodejs server and I am using PostgreSQL, the bottom part of my database. How can I select data and represent it like this (in one sql query): I wrote a request but it is far from what I need: Answer You can use a cte to first build the question JSON data, and then aggregate