This does us no good. You're showing a table missing something and a query that isn't. What you need to show us is the actual code that does the table population.
As a bit of a sidebar, you're wasting 20% of the table space associated with your dates by converting them to VARCHAR(8). VARCHAR() carries an additional 2 bytes of overhead. If you must store them as character based, store them as CHAR(8). While we're at it, you have the dates originally stored as an INT. which is useless for any type of date time calculations without a conversion and then you more than double the number of bytes used by converting them to 8 character strings and still can't do much with date calculations. The DATE datatype would store the date in only 3 bytes (70% savings compared to VARCHAR(8)) and open up a world of temporal calculation abilities.
I guess I'll never understand why people do what the do to data in the name of data warehouses and other things similar.
is pronounced "ree-bar
" and is a "Modenism
" for R
First step towards the paradigm shift of writing Set Based code:
________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
"Change is inevitable... change for the better is not".
"If "pre-optimization" is the root of all evil, then what does the resulting no optimization lead to?"
How to post code problems
How to Post Performance Problems
Create a Tally Function (fnTally)