0

I have the following table:

Region IdDescription IdUser

Metropolitan Right 5

Metropolitan Left 6

Metropolitan Right 5

Metropolitan Left 6

Country Town Right 5

Country Town Left 6

Country Town Right 5

Country Town Left 6

Metropolitan Right 7

Country Town Left 8

And I want to query the kinds of IdDescription and the relapses of IdDescription (when the same user ask more than once a determined kind of IdDescription in the same region where he asked before) in each region. Like this:

Region IdRight IdLeft SubTotal RIdRigth* RIdLeft** SubTotal GrandTotal

Metropolitan 3 2 5 1 1 2 7

Country Town 2 3 5 1 1 2 7

*IdDescription Right Relapses

**IdDescription Left Relapses

2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by Taywin
0

So far, I could think of this...

SELECT region,
       sum(case when idDescription='Right' then 1 else 0 end) as idRight,
       sum(case when idDescription='Left' then 1 else 0 end) as idLeft
FROM tab
GROUP BY region

But that is only the first 3 column you would get... Not have time to tinker further now...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.