Skip to content

Tag: sql

add auto generate column with correlated subqueries in mysql

I want to add a column that auto generates value depending on other tables. There are 2 tables to work with. Table “finance” : Table “price” : And by executing this command I get this result I wanted to make the revenue_x_10 auto generated by doing something like this. But looks like I…

Alternative way to run a query with join

I have the below query: select m.name, m.surname,m.teacher, c.classroom,c.floor from table1 as m inner join table2 as c on (m.name=c.name or m.surname = c.surname); But it takes a lot of time to …

Oracle SQL where clause does not work for some dates

Below query works fine with the recent dates (for e.g. if the date is 20-JUN-16, 30-SEP-19). But if I query with date value set to 29-MAR-80, 01-JAN-94 it does not return any result. Wondering what could be the reason. Am not allowed to change the existing year format to YYYY. We are on Oracle 19c. Answer Her…

Find items in table with 2 specific sizes

I have items table where the item code repeats as it has different sizes, variants. I want to find items which has 2 specific sizes, ie size in both M/Y and Euro. Items table: Required, I want to query for item id 1 and 3. I was trying with SUM(), CASE but not able to figure it as it involves