0
I have a table with 2 columns (one with date (YYYY,MM,DD) and another with a numeric value). I want the table to be ordered only per year and in case of entries with the same year the "tie-breaker" factor is the numeric value. How can I do?
0
I have a table with 2 columns (one with date (YYYY,MM,DD) and another with a numeric value). I want the table to be ordered only per year and in case of entries with the same year the "tie-breaker" factor is the numeric value. How can I do?
0
Well, in Mysql I would do so (use as a base for another bank). Your query should return all fields through *, and through the Year function return only the year as a field. Note: Year is a Mysql function.
SELECT *, Year(data) AS ano FROM nome_da_sua_tabela ORDER BY ano;
gives me syntax error in "year". I don’t know if it helps to say I’m using PUTTY
Which database you are using?
You managed to solve?
Yes, I did! Thank you for your help
Browser other questions tagged sql date classification
You are not signed in. Login or sign up in order to post.
depends, which database are you using? only use a function that extracts the year of the date, but need to know which database... would be for example
order by YEAR(coluna), outra_coluna
– Ricardo Pontual
I have a secure table with apolice columns, date and coverage. I want a list of apolices ordered by year and in case of "tie-breaker" sort by the amount of coverage. I tried the command:
– Filipaaaaa
select apolice from safe order by YEAR(datai), cover asc; But gives error...
– Filipaaaaa
as I commented, need to know the database,
year
is a function tosql-server
– Ricardo Pontual
Place the database you are using, if possible insert the tables used to better understand the question :)
– Maurício Krüger
I have another question: I need a query to return the mark with the highest number of accidents. I have three tables I need to use: vehicle, accident and acid_veic. Each accident has a number, the n_acid and I need to go to the accident tables and vec_acid see which vehicles involved in each accident. In the accident table the number of the crashed vehicle is in the column "safe vehicle" and in the table acid_veic the number of the crashed vehicle is in the column "vehicle". Then I have to group them by tags and count to see which one repeats more times, so the query return me this mark
– Filipaaaaa