Search This Blog

Friday, September 13, 2013

SQR: BEGIN-SELECT to get Count value


In SQR, we use below select construct to retrieve data from database.

BEGIN-SELECT
COL1
COL2
.
.
FROM TABLE_NAME
WHERE CRITERIA
END-SELECT

Now I need count of EE working in Department '10'. Below is the code to achieve this.

BEGIN-SELECT
COUNT(EMPLID) &Count_EE
FROM EE_DEPT_TBL
WHERE DEPARTMENT_ID = 10
END-SELECT

Sometimes, by mistake we might use #Count_EE as column variable since the value of Count is numeric. So coming to basics, all column variables will be referred with & (Ampersand).

No comments: