0

Whats wrong with sql statement?

I'm solving SQL problems and came across simple task which sound like: Get the first name,city and the total invoice of all the customers living neither in Paris, Prague, nor Rome and whose invoices are between $35 AND $38. This is is how my sql statement looks like: SELECT FirstName,City,InvoiceTotal FROM Customer WHERE Country IN ('Paris', 'Prague', 'Rome') OR InvoiceTotal Between 35 AND 38;

13th Sep 2018, 2:55 PM
Profs Stars
Profs Stars - avatar
5 Réponses
+ 6
Maybe because you confuse city with country?
13th Sep 2018, 3:23 PM
Anna
Anna - avatar
+ 2
Did you mean "either or" or "neither nor"?
13th Sep 2018, 2:57 PM
Janning⭐
Janning⭐ - avatar
+ 1
This selects first name, city and total invoice for customers outside Paris, Prague and Rome, whose total invoices between $35 and $38: SELECT FirstName, City, InvoiceTotal FROM Customer WHERE Country NOT IN ('Paris', 'Prague', 'Rome') AND InvoiceTotal Between 35 AND 38; Check if it was what you were after, good luck : )
13th Sep 2018, 4:29 PM
Ipang
0
Looks like he wants to get the FirstName, City and Invoice total when the Country is exactly Paris, Prague or Rome or when the Invoice total is between 35 and 38. I guess we'd have to look at the records in your database to check if one of these two conditions have been met.
13th Sep 2018, 3:05 PM
SQL Guy
0
Try this SELECT FirstName, City, InvoiceTotal FROM Customer WHERE City IN ('Paris', 'Prague', 'Rome') AND InvoiceTotal Between 35 AND 38;
13th Sep 2018, 6:46 PM
SQL Guy