Tag Info

New answers tagged

10

As was pointed out in ypercube's answer, when there is no ORDER BY clause there is no defined order. What I would like to add is that it's important to realise that SQL is very much an abstraction, it does not specify step by step what the DBMS is to do but rather specifies your requirements of the end result. This implies that if the data is already ...


14

No, your colleague is wrong. All SQL proroducts - DBMS that behave according to the SQL standards - provide no guarantee that the result of a query output will be ordered in any way, unless there is an ORDER BY clause in the query. As the IBM DB2 docs mention: Ordering is performed in accordance with the comparison rules described in Language elements. ...


0

To respond to your question, if you want to validate multiple conditions for a case statement, you can use coalesce or nest case statements. However judging by what you want to do, it might be best to handle this within your application. SQL Server is not made for computing, it's a database, inherently meant to store and produce data. As such it's been ...


0

This is a "top n per group" problem but within the limits of MySQL. You need to GROUP first then join back SELECT F.* FROM ( SELECT MIN(availability) AS MINavailability, id_product FROM foo GROUP BY id_product ) X JOIN foo F ON X.id_product = F.id_product AND X.MINavailability = F.availability ORDER BY F.availability, ...



Top 50 recent answers are included