I think that Pituach has already answered your question (and it is basically the same thing I said in my post, although I missed to point out one column as suspicous in the GROUP BY list). I would however like to question your table design.
In your tables, the only non-nullable column is the primary key, and this is an IDENTITY column. There is nothing wrong with nullable column, but you need to have an understanding what NULL means for that column and how it should be handled. For instance, you have CurrencyISOCode as nullable. All curencies have a three-letter code, so this column should be char(3), not nullable, and have a UNIQUE constraint.
Your current design opens questions like "what does a NULL value mean" or "what does it mean that there are two rows with CurrencyISOCode = 'USD'". I would suspect that you write your queries on the assumption that this does not happen, but then you should encode that in your database, because you will later to have fight problems because of bad data.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
No comments:
Post a Comment