Skip to content
Advertisement

Tag: sql-order-by

Mysql use 2 functions in 1 query

I’m trying to use 2 same functions in 1 query which is this This uses only the first function and give right result for the first latlngs only. I need the row which is almost near to the 2 latlngs (the latlngs is just example don’t care if it’s wrong <3 ) I want it to Give me the row

How order by case and order too?

i have a query for my next table This could be the sql query : but now i need order by case: example: when ‘Scholar’ then 1 desc its possible do that? my goal is order by id, and by case type example: the result will be: Answer Your question suggests that want a new direction within each group: However,

MYSQL Specific Order With Conditionals

Okay… I have three columns that I’d like to order based on their conditions. Column 1 (INT) = last_reboot Column 2 (BOOL) = onlinecheck Column 3 (INT) = drive_use I’d like “last_reboot” to be default and ordered descending. If “onlinecheck” = 0, I’d like it to be at the top of my query else ordered by the the “last_reboot” desc.

SQL Case Order By specific order and Direction

I have a table that I need sorted on fields By @SortBy and @SortDirection, for ID,PriorityID,stateType (column type is int) result is OK, but for Title (nvarchar) Query Result is: Conversion failed when converting the nvarchar value ‘Title Column value’ to data type int. Query: Answer The types are different, and that is a problem for the case expressions. The

How to increment column by one group wise

I have a table called productLocation, and its data structure as follows, SQLFiddle For each location have its own sorting order for products. But some of the products have 0 as the SortValue Now I need to write a query to update SortValue as, If I consider one location, FkLocationId = 1 In the above data table, you can see,

Advertisement