Hi there sqlthirts There seem to be multiple errors in there I'm afraid, did you develop this yourself or is it's someone else's code or perhaps and assignment? The way to debug it is to take a look at each statement in turn and work out where the problem section is, you'll find that most of it runs but one section wont. Once you find that section then you can have a look there to see what the problems are, if it's a complex section then look to simplify it i.e. work on sub queries rather than the entire query to see what you can spot (or what the error is in the messages windows, it will tell you what's wrong). Feel free to ask any other questions or share your findings along the way and I'll work with you to achieve the correct outcome. Hope that helps, here all afternoon :) Mart P.S. some hints: Brackets () need to be in pairs. DESC is a reserved word. Review INSERT statements noting how they are written (hint, look at the table default values too) Columns in two tables can only be used for comparison if both tables contain those columns.
That's a lot of code to digest. It took me a couple of minutes just to get rid of the line numbers! I reckon you've got a bit buried in the details here. How about getting a cut-down example to work first? Just the minimum 2 or 3 columns in each table. Either that will still fail, in which case you can post the simpler version here and people might be able to help more easily. Or it might work, in which case you can add the other columns back in. Don't add them all at once. Just do 2 or 3 at a time and test each iteration.