Get last data for rows [closed] - mysql

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
I have table like this :
then i want query data like this :
how did to do that?

A subquery with group by should do the job:
select * from <table_name>
where (serial_number, attempt) in (select serial_number, max(attempt) from <table_name> group by serial_number)

Related

Trying to combine two sql queries into one: Combining a with clause with Count/Group By [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
Image of two sequel queries
Basically, I want it to display all films with language name spanish and show the amount of actors in each.

my sql select Query not working what is we expected [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
class table
class table
students table
students table
teacher's table
teacher's table
expected output table
expected output table
i tried left join but i am getting multiple record's getting.

Not able to delete complete row in SQL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last year.
Improve this question
Wanted to delete complete row, which contains NULL entries in sql with command
DELETE FROM student WHERE ID=NULL;
What is wrong in this code?
Your syntax is incorrect you need to check for IS NULL
DELETE FROM student WHERE ID IS NULL;
Adding link to documentation thanks to D M
Working with NULL values

how to find a record between two values [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have the following table where there are two relevant fields for searching, this is 'from' and 'to' and represents the range of employees and then the field 'InitialQMSDays' represents the value that I want to return.
So if I have a search value of say 6, it would look at that value and find it between the 6 - 10 row, and return 2.
any ideas?
SELECT InitialQMSDays
FROM my_table
WHERE 6 BETWEEN `From` AND `To`;

Sort data from MySQL table [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a MySQL table named camp_details which has the following columns :
camp_id, camp_name, location, category, months , pattern
I have input fields which accepts values for location, category, months and pattern.
Based on the details provided, the table should sort according to the preferences (1:location , 2:Months , 3:pattern and 4:category).
That is, the table should display first containing location, next months and so on.
Kindly help me out in this.
just use this query
SELECT * FROM camp_details ORDER BY location , months,patter,category ;
or use DESC after column name which you want to sort in desc like
SELECT * FROM camp_details ORDER BY location , months DESC,patter,category ;