I want to get numbers of rows in a table according to certain criteria.
Please see the below table:-
Herein I want to get numbers of rows according to Column StationTo. I want to get numbers of rows of each StationTo entries.
I want to get numbers of rows in a table according to certain criteria.
Please see the below table:-
Herein I want to get numbers of rows according to Column StationTo. I want to get numbers of rows of each StationTo entries.
You could group by the StationTo
and use the aggregate count(*)
function:
SELECT StationTo, COUNT(*)
FROM mytable
GROUP BY StationTo
EDIT:
If you just want the number of rows for a single StationTo
, you could use a where
clause:
SELECT COUNT(*)
FROM mytable
WHERE StationTo = 'P11004400000'
Select StationTo,Date, count(*) from table group by StationTo, Date
meaning all the stationTo having rows display their count.
or select count(distinct StationTo) from table
or Select count(*) from table where stationTo='yourvalue'
Hi have you master table for stationTo records?
select s.stationto, count(data.*) from stationtomaster
left join data on data.stationto=stationtomaster.stationto
group by s.stationto