MySQL: SUBQUERIES

preview_player
Показать описание
#MySQL #tutorial #course

SELECT first_name, last_name, hourly_pay,
(SELECT AVG(hourly_pay) FROM employees) AS avg_pay
FROM employees;

SELECT first_name, last_name
FROM customers
WHERE customer_id IN (SELECT DISTINCT customer_id
FROM transactions WHERE customer_id IS NOT NULL);
Рекомендации по теме
Комментарии
Автор

SELECT first_name, last_name, hourly_pay,
(SELECT AVG(hourly_pay) FROM employees) AS avg_pay
FROM employees;

SELECT first_name, last_name
FROM employees
WHERE hourly_pay > (SELECT AVG(hourly_pay) FROM employees);

SELECT first_name, last_name
FROM customers
WHERE customer_id IN (SELECT DISTINCT customer_id
FROM transactions WHERE customer_id IS NOT NULL);

SELECT first_name, last_name
FROM customers
WHERE customer_id NOT IN (SELECT DISTINCT customer_id
FROM transactions WHERE customer_id IS NOT NULL);

BroCodez
Автор

After so many wrong and complicated examples on this topic finally a good and clear explanation, it helped me thanks.

adriatic
Автор

In just a few minutes you made me understand what they explained to me at school for almost a month

faidex
Автор

great video explanation was very clear

igor
Автор

Yo, I've been watching and learning from this course, soo much. I've tired learning SQL from books, but you explain it very easy.
You are a hero, thank you BroCode!

mostwanted
Автор

This is simplified...have been racking the brain for some days now..a milliin thanks

chikabenie
Автор

Finally I've been looking for a good explanation all week and you delivered 🙌

quantumjunction
Автор

i am also learning to use subquerry's. Tbh it's pretty damn hard, but i feel like it's one of those things you learn with much much practice

Siuuu-gyro
Автор

Couldn't have explained it in a better way... appreciate it man!!!

mr.nobody
Автор

A very clear and concise explanation.❤❤❤

chetanvashisth
Автор

Bro Code, from the bottom of my heart: THANK YOU.
I'm learning sooo much from your videos, you're a life saver.

mixowentz
Автор

My professor made this more complicated than it seems. Thank you!

Arzene
Автор

best video about this argument, ty so much

yuss.
Автор

The customer and transactions example would be normally done with JOIN:
SELECT DISTINCT first_name, last_name FROM customers
JOIN transactions ON customers.customer_id = transactions.customer_id;
it's a bit shorter query, but it's cool to see that you can do this with other methods as well.

damiankadziela
Автор

Hi bro, thanks for the vid. Much better than most creators do. Much appreciated

enriquepasa
Автор

thanks man u explained it really chill, not like the other ones with all weird ass terms that i dont even know

pepijnschaap
Автор

Thank you so much❤You explained so good❤Keep your work up❤You are insane

jugmilic
Автор

I finally got to understand this topic. This was amazing.
Kudos and Bravos😂

AdebankeBamidele
Автор

I think you should touch on the performance too! These subqueries can be costly and suck up CPU in large tables. In the first example, the average was computed per row while $14.35 was needed only once. Other than that, great video. Thanks!

arielespindola
Автор

I have really enjoyed following your tutorials. I would like to complete some of the exercises on my own system. Are there files available to create the DB and data that you use in your videos? They would be greatly appreciated.

rodneyivers