Show in the tables, only the last statues [closed] - mysql

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

Related

Updating a column with a Count of data from another column in the same 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 2 years ago.
Improve this question
As the title suggests, trying to take the count or possibly distinct count of a column, we call it year, to count the number of a years for an individual or populated ID and place it another column in the same table. Here is an idea of what I have so far and we want to update the table. Thank you.
Join group table to updated table directly:
UPDATE outputtable O JOIN
(SELECT personID, COUNT(DISTINCT year) AS countYear
FROM outputtable GROUP BY personID) temp ON O.personID=temp.personID
SET O.N=temp.countYear

Duplicate value while using Group By [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 3 years ago.
Improve this question
SELECT location,special,price FROM `tickets`
WHERE event = 'food' GROUP BY location
I think you want, (assuming its mysql) the following:
SELECT location, ANY_VALUE(special) special, ANY_VALUE(price) price
FROM tickets
WHERE event='food'
GROUP BY location ;
ANY_VALUE is strange aggregate function out of normal db standards that returns one of the values arbitarily.
If you wish to not have duplicate results in your rows you can choose only distinct result set.
SELECT DISTINCT location,special,price FROM tickets WHERE event = 'food' GROUP BY location

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;

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

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

Linking two MySQL tables [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
Even this is asked a billion times here already, none of them has worked for me.
So: I have two tables:
banhammer_bans:
and banhammer_players:
What sort of query should I make that it gets the name value from the "players" table corresponding to the "player_id" and "creator_id" value? I've tried with JOINS and UNIONS but no success.
Select p.name, p.id as player_id, b.creator_id as creator_id
from banhammer_bans as b
inner join banhammer_players as p on p.id = b.player_id
You can use something like this:
select
*
from
banhammer_bans, banhammer_players
where
banhammer_players.player_id = banhammer_bans.id
This is a kind of Join too, but it has some sort of efficiency problems.