Query to find man of the tournament [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a table which has the below data:
PLAYER RUN
-----------------
Kohli 100
Kohli 200
Sachin 200
Yuvi 300
Yuvi 300
Yuvi 300
I need to return the Player's name who scored the maximum number of runs.
How can I achieve this by a SQL query ? In this case the query should return "Yuvi" .

Could you please use the query given below
SELECT TOP 1 PLAYER, MAX(RUN) AS MAXRUN FROM <TABLE> GROUP BY PLAYER ORDER BY MAXRUN DESC;

select player from (select player , sum(runs) from test group by player,runs order by sum(sal) desc) where rownum=1;

You should use Max function in the column RUN. The query will be,
Select PLAYER, MAX(RUN) from TABLE;

Related

SQL query where [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 months ago.
Improve this question
I have question about sql query
I use
select * from where
I like to know how to create a SQLitle query with the teams who win and possible_win %.
table is simple.
Team1,Team2,Team1_gols,Team2_gols,Team1_possible,Team2_possible
Table data is:
enter image description here
answer be only
team who win and possible win less 50
Try following query:
SELECT * FROM TABLE_NAME where
(V_G > H_G and Possible_win_V <50) -- V_G Won & Possibility of winning < 50
OR
(H_G > V_G and Possible_win_H <50); -- H_G Won & Possibility of winning < 50
I think this is what you're looking for:
SELECT *
FROM Table1
WHERE (Team1_gols > Team2_gols AND Team1_possible < 50) -- team 1 wins with < 50 probability
OR
(Team1_gols < Team2_gols AND Team2_possible < 50) -- team 2 wins with < 50 probability

query to check multiple revsions on a table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Need a query to check ids with multiple revisionnums
id reviionnum
1 0
2 0
1 1
3 1
2 1
The query should result
id revisionnum
3 1
Please help
If you want ids with only one revision number, you can use aggregation:
select id, min(revissionnum)
from t
group by id
having count(*) = 1;
The min() is the value if there is only one row.

How can I count repeat rows in SQL Server 2012? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to assign one unique number for each repeated row in select statement.
table
Name | Position
Mark Wol 1
Mark wol 1
MArtha 1
Martha 1
and I want this
1 Mark Wl 1
2 Martha 1
You can use as few or as many rows as you want. If you want to use all of the rows, list them all.
SELECT Row1, Row2, Row3,
ROW_NUMBER() OVER (
PARTITION BY Row1, Row2, Row3,
ORDER BY Row1
)
FROM Table
The best solution is to already have a unique ID for each record and then you are choosing to show that (which will come from the first found record)...
SELECT name,COUNT(*),id
FROM test_table
GROUP BY name
HAVING COUNT(*) > 1

Assign values to sorted result in SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have got table like below after sorting in SQL:
M_ID
-----
2013/01
2013/02
2013/03
2013/04
2013/05
2013/06
Now I want to assign each entries a particular value like below
M_ID Days
--------------
2013/01 20
2013/02 30
2013/03 40
2013/04 50
2013/05 60
2013/06 70
So, can you please let me know how to do that in SQL Query?
Do you mean something like this (presuming sql-server)?
SELECT M_ID,
Days = (ROW_NUMBER()OVER(ORDER BY M_ID) + 1) * 10
FROM dbo.TableName
Demo

Counting frequency of customer [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this table on sql sever
cstomer |No_Nota
CUS000 | 98342
CUS000 | 98343
CUS000 | 98343
CUS001 | 98355
CUS001 | 98355
I would like to count the frequency of each customer. For similar number of no_nota the value is 1.
I'd like a result like this:
cstomer |Frequent
CUS000 | 2
CUS001 | 1
You want the distinct count of the column no_nota, so that's what you should select...
select customer, count(distinct no_nota) as frequent
from my_table
group by customer
You want to count the result of your select query:
SELECT COUNT(expression)
FROM tables
WHERE predicates;
Example:
SELECT COUNT(No_Nota) FROM your_table WHERE No_Nota > 0;
Sounds like you just want a group by statement to get a count of all individual customers. Something like:
SELECT cstomer, SUM(1) as Frequent FROM table GROUP BY cstomer, No_Nota