I don't see a join condition between the two tables: lwc a, ldt b
Have I missed it? Is that intentional?
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
No, there is no join between the two tables but I did use 2 tables because I need different data from the 2 tables.
Thanks,
You do realise that will generate an initial result set (before grouping) which will contain all possible pairings of rows from the two tables? (Cartesian Product)? That might explain why you're out by a factor of four in one case. I'd start thinking about that before looking any further for errors.
P.S. use the "Post Reply" to keep everything in the same thread.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Originally posted by kiranmayi I need to use group by because I am using other queries with union function.
I don't doubt that - but it's only by breaking down ("analysing") your query that you'll fix it. You should start by looking at the result of this:
Code:
select decode(state,'TX','ZDA Target','OK','','MO','','KS','','AR','') "STATE",
decode(dep_month,1,'JANUARY',2,'FEBRUARY',3,'MARCH',4,'APRIL',5,'MAY',6,'JUNE',
7,'JULY',8,'AUGUST',9,'SEPTEMBER',10,'OCTOBER',11,'NOVEMBER',12,'DECEMBER') rep_month,
target_value cnt
from lwc a, ldt b
where DMA_STATE_IND='STATE' and DA_LU_IND='DA' and a.region='TEMP'
Put the result in a table (or a spread-sheet) so that you can play with it. If that's not right, the rest can never be.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
I do not want to get the second row in the result . . . without anything under STATE column
Does this mean you just need to add to the WHERE clause:
AND state = 'TX'
? ? ? ?
Did the presence of the other four states "multilply data by 4." ?
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Bookmarks