Reputation: 175
In my Database I have a table called ARTICLES
. In ARTICLES
I have 2 columns.
Now I want to get the max value of NRRENDORDOK
column where the TIP
column has value 'A'.
e.g. the max number of cells A in TIP column is 8.
Any help will be appreciated.
Upvotes: 2
Views: 680
Reputation: 1787
Use SQL MAX() aggregate function
select Max(NRRENDORDOK) from table where tip='A'
Upvotes: 2
Reputation: 69514
SELECT TOP 1 nrreddordok
FROM TableName
WHERE Tip = 'A'
ORDER BY nrreddordok DESC
Upvotes: 1
Reputation: 13700
SELECT tip, MAX(nrreddordok) FROM table
where tip='A'
GROUP BY tip
Upvotes: 2
Reputation: 7301
You should take use of the MAX
function and then GOUP BY tip in order to get the max value for each tip
:
SELECT tip, MAX(nrreddordok) FROM table GROUP BY tip
If you just want values for A
then you can use following query:
SELECT MAX(nrreddordok) FROM table WHERE tip = 'A'
Upvotes: 1