Skip to Content
0
Former Member
Oct 04, 2013 at 07:22 AM

Grouping of the same column in to two groups based on condition

126 Views

Hi All I need to group the data of a table for the same column values into two groups. I'll explain my requirement with a small data as below

Person Pet Cost

Count

John dog 20 1 John cat 10 1 John fish 10 1 John fish 20 1 Joseph dog 30 1 Joseph dog 20 1 Joseph cat 10 1 Joseph fish 10 1 Robet dog 30 1 Robet cat 10 1 Robet cat 20 1 Robet fish 15 1

Now my report should first group the data based on peson and then on pet, but when grouping with person all terrestrial animals in one set and fish alone in seperate set. so the report should look like this

Person Pet sum (cost) sum( count)

john

dog 20 1

cat 10 1

cost 30 2

fish 30 2

cost 30 2

joseph

dog 50 2

cat 10 1

cost 60 3

fish 10 1

cost 10 1

Robet

dog 30 1

cat 30 2

cost 60 3

fish 15 1

cost 15 1