Sql help


Sql help

I'm working on big SQL need help on grouping nulls as we'll not nulls


select a,b.....sum(),....

from(select a,b,c,d......

         From ( select s,g,h.....

                   from a inner join b on ....

                    Left outer join

                      (Select a,b,c....

                         From a

                          Inner join b

                            On ..


                           Select a,b...

                           From a

                   ) a1

         Inner join....

Still lots of joins there

finally grouping 

) c1

group by


my problem is when grouping I need to get Null & as well not null...but I'm getting only null grouping 

for ex:

col1 col2

1.      Null

1.       4555

1.       4555

1.       Null 

1.       Null

when I do group by only null grouping is coming but I need both null and not null grouping please need help


Tags (1)

Re: Sql help

Can't understand completely.  In your final select you have a,b,c...sum().  and in the example outpu you show only 2 columns col1 and col2.

can you explain what you mean by null grouping.

is it the group of a, b c.. where all three values are null ?


Re: Sql help

Sri, there are around 20 fields so I just given example. 

Grouping of around 10 fields in which 5 fields are null 

col 1 col2 col3 col4 col5 col6 col7 col8 col9 col10

1. 2. 3. 4. 5. N N N N N

1. 2. 3. 4. 5.

N - null 

group by only pulling out null group . I need both null and not null group summary

hope u understand

Junior Contributor

Re: Sql help

If it actually omits valid combinations i would consider it a bug.

But you probably do something in your query to produce that result.

Can you share the SQL?

Teradata Employee

Re: Sql help

Can you also share the sample output against the sample values, to better understand what you require.