select distinct with two fields

Hi,

I have the following situation

TABLE DESCRIPTION
I THINK THIS IS LIKE A SELECT DISTINCT OR SOMETHING ELSE, ANY IDEA?
LVL 1
joyacv2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sdstuberConnect With a Mentor Commented:
same idea as previous question, but you need to extend the group by
and order it


SELECT category cat1,
       cat cat2,
       COUNT(*) quantity,
       COUNT(CASE WHEN TYPE = 'P' THEN 1 END) type_p,
       COUNT(CASE WHEN TYPE = 'T' THEN 1 END) type_t
  FROM yourtable
GROUP BY category, cat
ORDER BY cat1, cat2 DESC;
0
 
sdstuberCommented:
it would help if you posted data in text form
images aren't usable
0
 
joyacv2Author Commented:
Ok give some minutes
0
 
joyacv2Author Commented:
table 1

cat1 cat2      type
A2      MOS      T
A2      MOS      P
BT      MOS      P
A2      GH              T
BT      CH              P

Table desired
cat1 cat2     Quan T-T   T-P
A2      MOS      2      1      1
A2      GH              1      1      0
BT      MOS      1      0      1
BT      CH              1      0      1
0
 
joyacv2Author Commented:
perfect, i understand the concept!!!! Thanks!!!!
0
All Courses

From novice to tech pro — start learning today.