MySQL - Featch Records with limit in one table [closed] - mysql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have one table with 3 fields e.g.
Name, Team Name, Player_Number
there is multiple team and I want to fetch 2 member from each team.
Please share with fast solution.

Try this
select * from TableName s where (select count(*) from TableName a where a.TeamName = s.TeamName and a.Player_Number >= s.Player_Number) <= 2

Related

How to improve this select statement [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 7 months ago.
Improve this question
I wrote this SQL
select *
from t_info
where contract_id <> "" and status <> "unfinished"
order by id asc;
but it takes more than 4s. I wonder how to improve this SQL? Thank.
Please don't use "<>" in where condition, while you need to use index.
select * from t_info
where LENGTH(trim(contract_id)) > 0
and (not status = "unfinished")
order by id asc;

I want data from datatable and replace comma with space [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 years ago.
Improve this question
I have query for to get data following :
select a from REPLACE(M,',','')TABLE;
I want to get all the data from table along with M column content replce , with space.
You select from the table. What you select belongs in the SELECT clause:
SELECT t.*, REPLACE(m, ',', '') FROM mytable t;

Show in the tables, only the last statues [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 years ago.
Improve this question
I have a simple entry in the oracle, there are 3 columns, date, API name and status. I want that in the answer I had not all history, and only the last on each of Names of API (only 7). I will be grateful for your help. I know that asked of the very difficult but I'm just new to oracle.
select l.log_date,l.job_name,l.status from user_scheduler_job_log l
could be you want the related status for name and last log_date
select u.job_name, u.status, t.max_date
from user_scheduler_job_log u
INNER JOIN(
select MAX(l.log_date) max_date, l.job_name
from user_scheduler_job_log l
GROUP BY l.job_name
) t on t.max_date = u.log_date
AND t.job_name = u.job_name

MySQL - Find the lowest unique value in 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 4 years ago.
Improve this question
So I have a table for biddings, you can win the bidding by posting the lowest unique bid. So if 2 people place a bet of $1, none of them win, if 1 person places a bet of $2, this guy wins. But how can I check this in MySQL?
Assume your table has the bid value stored in the field name bet, then below is a worked solution:
SELECT * FROM YourTableName
WHERE bet = (SELECT MIN(bet) FROM YourTableName)
GROUP BY bet
HAVING COUNT(*) = 1;

String retrieve Function in SQL Query [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 7 years ago.
Improve this question
I am having a database with 2 columns employee and job.Job column contains character in each record.In that,I have to list the employees whose job is having last 3 characters as 'man'.I have to use only functions in SQL Query.
Use LIKE with wildcard:
SELECT *
FROM your_table
WHERE job_column_name LIKE '%man'
or using RIGHT
SELECT *
FROM your_table
WHERE RIGHT(job_column_name, 3) = 'man'
Answer For Question 4 is
SELECT *
FROM emp
WHERE SUBSTR(job,-3,3)='MAN';