Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

I am trying to get distinct column value and count in db2

sIGPAD_PORT
80
80
3334
3334
10
II am trying to get the following from the table above


80 2
3334 2
10 1



.
[COUNT[DISTINCT ]]SIGPAD_PADPORT] asSIGPAD_PAD, ProjectId
FROM TBLUSERSESSION
WHERE EmpId IN 
]
    EmpId
    FROM TBLUSERSESSION
    GROUP BY SIGPAD_PADPORT
    HAVING COUNT >=1 
    ]

Open in new window

Avatar of r3nder
r3nder
Flag of United States of America image

ASKER

[COUNT[DISTINCT ]]SIGPAD_PADPORT] asSIGPAD_PAD
FROM TBLUSERSESSION
WHERE EmpId IN 
]
    EmpId
    FROM TBLUSERSESSION
    GROUP BY SIGPAD_PADPORT
    HAVING COUNT >=1 > 1
    ]

Open in new window

SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

I gget an error
SELECT SIGPAD_PORT, COUNT(SIGPAD_PORT) AScntr
FROM TBLUSERSESSION GROUPBY SIGPAD_PORT

Open in new window

unexpected token SIGPAD_PORT was found following LUSERSESSION GROUPBY - I thought maybebe a mispelled column name or  incorrect case but both  are right
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SELECT SIGPAD_PORT,
       COUNT(SIGPAD_PORT) AS cntr
  FROM TBLUSERSESSION
 GROUP BY SIGPAD_PORT
;

Open in new window

Avatar of r3nder

ASKER

I am unsure what you were saying ken but it was close to the solution - thank yoyu and to eveyone else as well