How can i do a select count(artc_id) as cval, max(srt_id) as maxval, artc_title from table where artc_pub = 1
So I can get results like:
cval | maxval | artc_title | artc_pub
-----------------------------------------
4 4 Title 1 1
Title 2 1
Title 3 1
Title 4 1
Part of my table is below
artc_id | srt_id | artc_title | artc_pub
-----------------------------------------
1 1 Title 1 1
2 2 Title 2 1
3 3 Title 3 1
4 4 Title 4 1
1 5 Title 1 2
2 6 Title 2 2
I tried select count(artc_id) as cval, max(srt_id) as maxval, artc_title from table where artc_pub = 1 but this gives me only a single line with the first title. I guess there must be more than a plain old select here.
All the answers below give me results like this:
cval;maxval;artc_title
1 ; 1; Title 1
1 ; 2; Title 2
1 ; 3; Title 3
1 ; 4; Title 4
1 ; 5; Title 5
Not like how I mentioned up in my question.
You should be able to use
GROUP BYhere to group the results by the “article title”: