I have a table named pt_products with the following fields id int(11) NO PRI auto_increment merchant varchar(64) NO MUL filename varchar(255) NO MUL name varchar(255) …
Inserting into table1 from select table2
I have the following two tables: postgresp=> d tempo Table “postgres.tempo” Column | Type | Collation | Nullable | Default ————+———-…
Converting Date in Where clause in SQL
I need to return the sum of something within the last 30 days. My date field is a text field. My table looks something like this: Client Serial# Hrs MyDate A 1 …
Trigger on Views in PL/SQL
I want to write a trigger in PL/SQL. My first aim is to compare two time_stamp data type (A and B). If one of these is bigger than another, for instance A>B, i will update columns on another table. …
SQL query to exclude records that already mapped with another column id and show rest to them
I am trying to achieve the following but not able to Id CatID CategoryName ————————- 1 1 Movies 2 1 Movies 3 2 Books 4 3 Tools What I am trying to …
Couldn’t return output with SRC Key in an INSERT statement
I want the OUTPUT clause to return both the source key and the target key like below : I am having this following error : Answer To be clear, in INSERT, UPDATE, and DELETE statements, you can only refer to columns from the target table in the OUTPUT clause. In a MERGE statement you can refer to columns from b…
Single query to split out data of one column, into two columns, from the same table based on different criteria [SQL]
I have the following data in a table, this is a single column shown from a table that has multiple columns, but only data from this column needs to be pulled into two column output using a query: Required result: distinct values based on the first 13 characters of the data, split into two columns based on …
mysql get result from join table
I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table…
How to list tables in desc order of how many times they’ve been used in MYSQL?
I need to make the script list the names of relational tables together with the total number of times each table has been used. The results must be listed in the descending order of the total number of times each one of the relational tables has been used. Here is my code so far: And here is what the ouput
How to get vowels in Like operator of SQL?
I was solving a problem on SQL from Hackerrank. I have to make a query such that it gives me all city names starting with a, e, i, o or u. I’m using Like operator but still wrong answer. Here’s the problem Link Here’s my solution- Can anybody explain? Answer LIKE does not support that partte…