Most voted "select-limit" questions
12 questions
Sort by count of
-
5
votes2
answers168
viewsClause similar to Mysql LIMIT in MSSQL
I need to run the query below in PHP with SQL Server, however I cannot use the clause LIMIT absent in darlings microsoft. $SqlTabelaAtual="SELECT * FROM BusinessCadTabPreco RIGHT JOIN…
-
4
votes3
answers902
viewsRETURN THE SUM OF MAXIMUM 3 SQL VALUES
I have a table and I need to return the following: check based on recipient column, add the 3 largest amount of that recipient, bring in query only if the sum of the 3 largest ones are >= 1024:…
-
3
votes1
answer90
viewsHow to limit rows per month in SQL
I have a list of products purchased with date and price, I wanted to organize in a query the ten most purchased of each month, type: mes | nome | total janeiro | arroz | 100 janeiro | feijão | 87…
-
1
votes1
answer53
viewsdoubt with Entity and limit
I need to retrieve the last 100 records from the bank, I’m using the code below, but it returns the first 100: dynamic data = null; try { data = limit == 0 ? (from p in contexto.Set<TEntity>()…
-
1
votes1
answer763
viewsHow to return the records between two values with the SQL Server Database?
Example of my table: My question is this... On my featured news page have to appear the 2 latest news and on the secondary news page have to appear the 2 other news in sequence. Example: in the…
-
1
votes1
answer561
viewsMysql SELECT with JOIN and LIMIT in child table
I have a table catalogo related to another table imagens. Each record in catalogo has N images. I need that in a SELECT with INNER JOIN imagens, only 3 images are returned for each table row…
-
1
votes1
answer578
viewsORDER BY or LIMIT. What is processed first in SQL Select?
Friends, what is first processed in SQL Select? "Order by" or "Limit"? For example, if I have a table with cities of several states. Then I search the cities with more than 100 thousand inhabitants…
-
0
votes2
answers1141
viewsPostgresql - Query data from a range and bring a boundary of lines but spaced
Good morning Guys, all right? I have a performance problem in a system and need to solve by customizing an SQL. Let us imagine the following scenario: - A table with millions of records, each record…
-
0
votes0
answers18
viewsMYSQL - Is there an alternative to LIMIT in the Queries?
I’m using MYSQL. I have the following table: create table visita ( id int, titulo_socio varchar(10), data_visita date, cidade_visitada varchar(50), status_visitacao varchar(50) ); A data example for…
-
0
votes2
answers153
viewsLIMIT and OFFSET duplicates data in mysql
I have a table in mysql but when using LIMIT and OFFSET I have an unwanted return, 1 data repeats to each search. Look at the table: then use the following command: SELECT funcionario.nome FROM…
-
0
votes0
answers27
viewsOptimize Mysql query with Sub Select
I was having a problem of slowness in a select as below: select vendas.codigo, vendas.cartao_tipo, vendas.valor, vendas.datavenda, venda.autorizacao, cliente.codigo, cliente.nome, cliente.cpf,…
-
-1
votes1
answer77
viewsSelect TOP 3 of every month
I need to return the top 3 of a query each month: select distinct mes, rubrica, count(*) qtd from boletins group by mes, rubrica order by mes asc, qtd desc; This query above returns about 30 lines…