I have a statement which works in SQL server 2008 but doesn't work in 2012
SELECT supplyType, supplyType FROM ITM_Items GROUP BY supplyType ORDER BY supplyType It gives this error message: Msg 209, Level 16, State 1, Line 4 Ambiguous column name 'supplyType'. I agree that statement is written "weird" but my question is why is working in some version and doesn't in other
It's the ORDER BY statement that's giving you the problem. I would have thought that wouldn't work in 2008 either. It is absolutely ambiguous. Since ORDER BY works off of aliases and is the last piece of processing, it makes sense that you would need to differentiate between the two columns. ORDER BY wouldn't know that they're the same. I tested in 2012 and 2014 and it fails in both. I didn't have a 2008R2 instance available, so I spun one up in Azure. I got the error there too.