SQL Question

Soldato
Joined
22 Nov 2007
Posts
4,209
Hey guys

Following an SQL course and i have a query and it hasn't been covered by the teacher.

I understand this sub query is using finding pairs, in this case 100 & 20 and 101 & 30. I understand that but, whats the point of having the WHERE clause of 01-jan-2015 if it its going to ignore it and pick a pair which has the date of 2/9/15?

What's the point?

edit: forgot image link

https://ibb.co/HhNyPGK

HhNyPGK
 
Its saying give me a list of data from the sales table where the product id and unit price are in this sub query. Its not ignoring it, its filtering the sub query.

Thanks.

If i wanted to return the result omitting the 2/9/15 row what would need to be changed?

edit: Just run the sub query on its own i guess?
 
Umm no not really, that's what the MAIN query is doing...
The subquery is finding ALL rows with a product_id and unit_price where sales_date is 01/01/15.
The main query is then using this data to filter the main query data columns.

Well its not strictly only finding where its 01/01/15 is it
 
Ahhh i’ve got it, the clue is in the name - Pairwise comparison. It finds the any rows that matches the date and then any other rows where the pairs match.

ok fine but as someone said thats a poor example if you only want to return sales on that specific date.

thanks all
 
Back
Top Bottom