comsol怎么快速入门
更新时间:2023-02-26 13:02
最满意答案
根据您以前的SO问题,您不需要提取名称,只需添加GROUP MAX即可:
-- copied from the accepted answer select p.* from people p join (select p1.first_name, p1.last_name from people p1 where p1.id = 17 )un on un.first_name = p.first_name where p.last_name like un.last_name || '%' -- ADDED order by -- find the MAX for each name max(col2) over (partition by un.last_name), last_name
Based on your previous SO question you don't need to extract the name, you simply have to add a GROUP MAX:
-- copied from the accepted answer select p.* from people p join (select p1.first_name, p1.last_name from people p1 where p1.id = 17 )un on un.first_name = p.first_name where p.last_name like un.last_name || '%' -- ADDED order by -- find the MAX for each name max(col2) over (partition by un.last_name), last_name
相关问答
更多-
在SQL中按顺序排序(Order by within an order by in SQL)[2023-12-23]
根据您以前的SO问题,您不需要提取名称,只需添加GROUP MAX即可: -- copied from the accepted answer select p.* from people p join (select p1.first_name, p1.last_name from people p1 where p1.id = 17 )un on un.first_name = p.first_name where p.last_name like un.last_na ... -
之后的SQL顺序超过(SQL order by after more than)[2022-05-28]
select * from (select id from student where id >= 3 order by id limit 2) r order by r.id desc select * from (select id from student where id >= 3 order by id limit 2) r order by r.id desc -
按逻辑顺序排序(sql order by logic)[2022-12-20]
您可以使用CASE WHEN使用以下解决方案: SELECT * FROM table ORDER BY intColumn DESC, CASE WHEN intColumn = 0 THEN stringColumn END ASC 在这里你可以找到一个例子: http : //sqlfiddle.com/#!9 / a982a / 1 You can use the following solution using the CASE WHEN: SELECT * FROM ta ... -
SQL ORDER BY“IF”(SQL ORDER BY “IF”)[2023-08-15]
你想先找哪个? 数字还是字母? 你的方法的问题是类型。 所以,先决定你想要哪一个。 。 。 说数字: order by (title REGEXP '^[0-9]+') DESC, -- put numbers first title + 0, -- order by numbers as numbers title -- order by everything else W ... -
您可以使用CASE自定义记录排序, ORDER BY CASE WHEN ID = 12 THEN 1 WHEN ID = 6 THEN 2 WHEN ID = 4 THEN 3 WHEN ID = 3 THEN 4 WHEN ID = 13 THEN 5 ELSE 6 END, ID SQLFiddle演示 you can use CASE to ...
-
SQL按字典顺序排序,但首先排序较长的字符串(SQL Order by lexicographical order, but with longer string first)[2022-12-26]
这似乎工作: declare @YourTable table (YourColumn varchar(100)); insert into @YourTable select 'bananaphone' union all select 'banana' union all select 'carpet' union all select 'car' union all select 'dishes' union all select 'carpet' union all select 'cars' u ... -
精确控制SQL排序顺序(Fine control over SQL Sort Order)[2022-03-11]
只需添加另一个计算表达式作为Expression的第一个顺序,这会使这两个值超过所有其他值... Select [Other stuff] From Table Order By Case colName When first_val then 0 When second_val then 0 else 1 End, colName 或者,编辑(包括@ astander的建议) Select [Other stuff] From ... -
在SQL Server 2000中按字段按字母顺序排序(Order by Field in non-alphabetical order in SQL Server 2000)[2024-01-03]
select * from Geniuses order by -- First, order by your set order... case FullName when 'Charles Babbage' then 1 when 'Albert Einstein' then 2 when 'Adrien-Marie Legendre' then 3 when 'Niels Henrik Abel' then 4 ... -
字符串评论答案; 这将给出与原始答案相同的结果但匹配字符串: string orgList = "John,Joe,Tippu,Rich,Chad,Chris,Rose"; List
orderArray = new List (orgList.Split(",".ToCharArray())); // the linq to do the ordering var result = ourList.OrderBy(e => { int loc = ... -
按SQL排序(Rails Order by SQL)[2022-01-09]
我不知道这是否适合你,但试试这个: @trait_question.traits.order('ABS(value)') ABS会将负值更改为正值,从而每次取绝对值。 如果你的数据库字段是string那么你可以这样做,如汤姆建议他为他工作: @trait_question.traits.order('ABS(CAST(value AS int))') I don't know if this will work for you or not but try this: @trait_question.t ...