0

I want Total rows of below SQL query.

SELECT ParameterName, MAX(param_Value), MIN(param_Value) 
FROM MONITORING_PARAMETER_VALUES 
GROUP BY ParameterName;

Result:-

   ParameterName | max(param_Value) |  min(param_Value)
   EDS           |               4  |                1
   Table's       |               10 |                5

So clearly number of row's are 2 And this is want to get using sql query.

1
  • @shA.t dont think that Count(DISTINCT ParameterName) wil help. let me edit the question. Commented Dec 30, 2015 at 11:39

3 Answers 3

2

The row count that the query would return is given by this expression:

select count(distinct parametername) + max(parametername is null)
from MONITORING_PARAMETER_VALUES;

Note that the expression considers NULL values.

If you want the rows returned by your query, one method is to enumerate them using variables:

SELECT (@rn := @rn + 1) as rn, MAX(param_Value), MIN(param_Value) 
FROM MONITORING_PARAMETER_VALUES CROSS JOIN
     (SELECT @rn := 0) params
GROUP BY ParameterName;
Sign up to request clarification or add additional context in comments.

Comments

0
Select Sum(cnt) as countCol
from
(
SELECT 1 as cnt
FROM MONITORING_PARAMETER_VALUES 
GROUP BY ParameterName
) as tab

try this

Comments

0

You can use @@rowcount after your query:

SELECT ParameterName, MAX(param_Value), MIN(param_Value) 
FROM MONITORING_PARAMETER_VALUES 
GROUP BY ParameterName

select @@rowcount

This will return the row count of the previusly executed select.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.