Reputation: 899
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.
Upvotes: 0
Views: 57
Reputation: 641
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.
Upvotes: 0
Reputation: 8545
Select Sum(cnt) as countCol
from
(
SELECT 1 as cnt
FROM MONITORING_PARAMETER_VALUES
GROUP BY ParameterName
) as tab
try this
Upvotes: 0
Reputation: 1269803
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;
Upvotes: 2