Issue I have 100000 products and 500 categories. every product is in 10 categories. products and categories are in many to many relation. i want to find 10 most related products by category. for example product P1 is in 1,2,3,4,5
Continue readingTag: sql-order-by
[SOLVED] How to keep mysql names together in ordered list
Issue I have the following list of items Category OrderNum Prerequisites 2 NULL 4 Prerequisites 6 Sign Off 8 Sign Off 10 I would like it to be ordered so that ‘Prerequisites’ is together and the NULL category appears after
Continue reading[SOLVED] Is there a [straightforward] way to order results *first*, *then* group by another column, with SQL?
Issue I see that in an SQL query, the GROUP BY has to precede the ORDER BY expression. Does this imply that ordering is done after grouping would have discarded identical rows? Because I seem to need to order rows
Continue reading[SOLVED] Update top N values using PostgreSQL
Issue I want to update the top 10 values of a column in table. I have three columns; id, account and accountrank. To get the top 10 values I can use the following: SELECT * FROM accountrecords ORDER BY account
Continue reading[SOLVED] LINQ Orderby Descending Query
Issue I have a LINQ query that I want to order by the most recently created date. I tried: var itemList = from t in ctn.Items where !t.Items && t.DeliverySelection orderby t.Delivery.SubmissionDate descending select t; I have also tried: var
Continue reading[SOLVED] EntityFramework. order by count of sub array elements
Issue I created three tables in Database using Entity Framework class User{ public string Name {get;set;} public IEnumerable<Pet> Pets {get;set;} } class Pet{ public string Name {get;set;} public IEnumerable<Toy> Toys {get;set;} } class Toy{ public string Name {get;set;} } I
Continue reading[SOLVED] Order by column should have index or not?
Issue I am adding indexes to table with millions of records which is used for searching results. I am showing results in ASC or DESC order. My question is should that column have an index or not? I have 2
Continue reading[SOLVED] Get row with largest negative number, or row with smallest number if there are no negative numbers
Issue I’m trying to write a Snowflake SQL statement that does the following: If there are negative numbers in column_A, return the row with the biggest negative number in column_A If there are no negative numbers in column_A, return the
Continue reading[SOLVED] How to select best customers and group them by how much they paid
Issue I am using SQL server to select this table and group the customer id and first name according to their total payments made to the store. I tried using select custid, name, sum(payment) from transactions group by custid order
Continue reading[SOLVED] PostgreSQL get results grouped by Name but ordered by modified_date desc for the first element of each group
Issue Suppose that my query: select modified_date, name from table1 where name in (select name from table2 group by name) as a order by name return this results: I need to change my query to get results grouped by Name
Continue reading