Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count statement

Status
Not open for further replies.

EPNICO

MIS
Jun 14, 2001
45
US
Hello:

Giving the following query:

SELECT M. POLICY_ID, EXRTCD=
( CASE WHEN COUNT(DISTINCT M.STATE_ID) > 1 AND
COUNT(DISTINCT M.ACTION_CODE_ADJ_VALUE_INPUT) > 1 THEN '3' END)
FROM WCPS.PERIOD_ACTION_CODE AS M
GROUP BY M.POLICY_ID;

I get an error stating there is something wrong in my syntax, this works im Ms Sql 7.0. I checked the help area in sybase for the count syntax the distinct verb is valid the only part that I'm not sure of is the AND.
Sybase does not like two count statements with distincts any ideas are welcomed.


 
Table aliasing doesn't seem to like "AS" in 11.9.2.

Try

SELECT M.POLICY_ID, EXRTCD=
( CASE WHEN COUNT(DISTINCT M.STATE_ID) > 1 AND
COUNT(DISTINCT M.ACTION_CODE_ADJ_VALUE_INPUT) > 1 THEN '3' END)
FROM WCPS.PERIOD_ACTION_CODE M
GROUP BY M.POLICY_ID

HTH,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top