Most voted "query" questions
Query or *query* refers to the act of recovering data previously stored in a computerised system from certain parameters and/or filters, by means of a specific command or operator.
Learn more…1,160 questions
Sort by count of
-
1
votes2
answers2225
viewsHow to take the sum of an entire column in SQLSERVER
I need to take the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithes are required. ex: total = VOL(7,6890028)…
-
1
votes1
answer74
viewsQuery string paging with codeigniter
How do I search with pagination using query string in Codeigniter? I’m trying to search in the documentation but couldn’t find it! I have following scenario:…
-
1
votes2
answers1174
viewsHow to do more than one select in the same query?
How can I do more than one select in the same query? I tried it this way (using UNION), but it didn’t work: DATABASE Table: cameras_lines id_camera_linha | nome_linha_camera Table: manufacturers…
-
1
votes1
answer1339
viewsPostgresql - Inserting data into linked tables by Foreign Key
Hello! I’m having a problem inserting data into tables linked by a foreign key. I read in some places that there is a command "with" that helps in these situations, but I didn’t understand how to…
-
1
votes2
answers159
viewsQuery mysql problem, what would be the best way to solve
Hello, I am trying to make a query for an order system for a restaurant. My tables are arranged as follows: I need to bring all tables (regardless of whether they have a request or not) if they have…
-
1
votes2
answers247
viewsQuery in the same table
I have a movement table that has worker’s record and related events, wanted a query that returns only the records that have exactly the events E1,E2 and E3, in the case of the above example the…
-
1
votes1
answer64
views -
1
votes2
answers167
viewsProblem with mysql_query, the data does not fall in the SQL database.
Hello, I cannot run this query, I echo this variable and all data is being passed, but it does not enter my BD. When I copy the command and paste it into the phpMyAdmin query works. Could someone…
-
1
votes1
answer1020
viewsGroup sum by month and year
I have a simple table in a FIREBIRD database: idCliente: integer dataPagamento: date valor: numeric How to make a select that adds up all amounts payable, grouping by month and year? kind of: select…
-
1
votes2
answers105
viewsConcatenate varchar2 PLSQL
I have 2 tables with relationship 1 to many and I need to concatenate all the values in the column Nome table 2 in only one select column. Ex.: In the example, the return of what I need would be…
-
1
votes1
answer43
viewsMYSQL - Query summing 8 identical tables
Good afternoon, I am very new in MYSQL, basically I am learning in network searches, but a question arose that I could not solve. I have about 6 tables, in each I have 10 fixed and identical entries…
-
1
votes0
answers353
viewsHow to join 3 queries of quantities of different records?
I need to unite 3 darlings with different results and quantities of records in a single query, using the Where end of script as Where main for all darlings. How can I do this? I tried with the…
-
1
votes2
answers1521
viewsQuery SQL - put result in a row only
SELECT pga.Titulo, e.Codigo FROM Qualidade_Diagrama_Processo_Grupo_Acao pga JOIN Qualidade_Diagrama_Acao_Entidade ae on (ae.Id_Proc_Grupo_Acao = pga.Id) JOIN Qualidade_Diagrama_Entidade e on (e.Id =…
-
1
votes1
answer680
viewsReturn Oracle PL/SQL string range
Good morning ! I need to return the value inside a string between a range of | in the select below I can get the value from the first |. The expected result is: 83,1 SELECT…
-
1
votes1
answer2093
viewsHow to format numbers directly by SQL
Gentlemen, my numbers are coming out without formatting when I perform the select directly at the bank, they are coming out as follows: REALIZADO META 61274436,2090003 80000000,00 How can I make…
-
1
votes0
answers333
viewsCreate select with multiple conditions
I have a table with several record of calls and I need to perform some conditions, to separate records. I already use select to validate the information SELECT count(*) as qtdade_status_dia,…
-
1
votes0
answers39
viewsReceive data from another page
Speak guys, I’m creating a store with a friend, one of the security measures is to check if the CPF really exists. thinking about it we found a website: https://www.situacaocadastral.com.br/ what…
-
1
votes1
answer237
viewsHow to bring a List in a JPQL query with constructor
Good afternoon, I’m doing a jpql query to bring up a VO(Value Object) with some information, one of them being a List. This list is in the object opCambio, however, is returning me this error: Log:…
-
1
votes0
answers114
views -
1
votes1
answer703
viewsAdd cases to a query
I need to create a query that adds up to 2 cases, but I’m not getting it the way I did. Case the field D3_UM = 'PC', he must add the field D3_QTSEGUM. Case the field D3_UM <> 'PC', he must add…
-
1
votes1
answer44
viewsRankin in in Mysql
I’m trying to generate a ranking of absences for HR. The record of absences is made in a separate table of the Employee’s registration. I need to bring the list of active employees and the amount of…
-
1
votes2
answers13773
viewsSQL query in VBA Excel
good morning! First I would like to say that I understand almost nothing of Visual Basic and that all I have learned so far is in the race on forums. So if this is too simple to resolve, forgive me.…
-
1
votes1
answer118
viewsSelect for a specific period in Mysql
I know that if I want to query the date 5 days ago, I use the following Query: SELECT * FROM Tabela WHERE Data = DATE_SUB(CONCAT(CURDATE(), ' 00:00:00'), INTERVAL 5 DAY); Or you want to go back two…
-
1
votes1
answer309
viewsAlternative to using view variables in mysql
I need to create a view that gets the percentage of each product in relation to the total of products, I made the query below and this working as a normal select: set @total := (SELECT…
-
1
votes3
answers190
viewsRun DELETE only when you return SELECT
I have a routine where I update the local database with the data from another database. I simply execute a DELETE and then a INSERT INTO tblX (SELECT * FROM tblY (tblY is a linked table)), as below.…
-
1
votes0
answers130
viewsHow to use Subqueries with LINQ Entity Framework?
I need to write the following query in the Linq Entity Framework. I’m having difficulty in the subquery part, where I need to accumulate the quantity field. SELECT ppc.[PedidoCompraId] ,ppc.[EAN]…
-
1
votes2
answers3778
viewsReturn the shortest date within Select
I have the following table: CREATE TABLE [dbo].[Crm_man]( [id] [int] IDENTITY(1,1) NOT NULL, [nCRM] [int] NULL, [cliente_CRM] [int] NULL, [item_CRM] [int] NULL, [qnt_CRM] [int] NULL, [descri_CRM]…
-
1
votes2
answers63
viewsSQL query leaving a custom column data
Hello! I wonder if it is possible to mount a query that returns me a table similar to this: The appB and appC data comes from a select Count in the Calls table that returns the amount of sessoes…
-
1
votes2
answers368
viewsCustomers who bought in one year but not another
I need to make a select that brings me which customers bought in 2016 and did not buy in 2017 and vice versa. This is my select: SELECT tc.`cod-emitente` AS CODIGO, tc.`nome-emit` AS CLIENTE,…
-
1
votes1
answer119
viewsList each user’s last message
Does anyone know how I could list each user’s last message? I was able to do that, but it lists the last message from just one user, and I wanted it to list everyone who sent a message to the user…
-
1
votes1
answer345
viewsCompare End Date of the first record with Start Date of the second
Hello. I’m having trouble drafting a SELECT that checks whether the End Date of the first query record is greater than the start date of the second. The database in question is of notes and for some…
-
1
votes4
answers2917
viewsFilter using only month and year on SQLSERVER
I need to mount a select, in which the filter is used only month and year in the parameters. This is the select I’m currently using, but I need the 'day' not to influence my search. SELECT…
-
1
votes2
answers881
viewsPHP Search system ignore uppercase letters and add keywords
I have a simple search system that searches for values in the comic book and displays on the page. In the table I have a column called palavraschaves where the words I leave as a query parameter are…
-
1
votes1
answer58
viewsquery Pdo error (Sort by Count)
I am trying to make a ranking based on the amount of coins each. In descending order. I used this query in Pdo: $ranking = $pdo->query("SELECT * FROM usuarios WHERE banido='false' GROUP BY…
-
1
votes2
answers1444
viewsConvert Integer to Decimal in Oracle
how do I convert a whole number to decimal on oracle? Today, the consultation coming out this way. 75 However, I want you to go out with 2 decimal places, that way. 75.00 Below is the syntax of the…
-
1
votes2
answers284
viewsQuery that only returns the result if a field is in another table
The title may not represent the question well. I have a table with information about cars (id(CP), name, model, among others) and another one with the "Extras" (id(CP), id_carro(CS), name_do_extra)…
-
1
votes1
answer128
viewsDo I want to show the birthday boy two days before or after the event?
I have a consultation that shows on the system Dashboard the birthdays of the week, all who make birthdays between Sunday and Saturday are displayed on the screen, but it is very annoying to watch…
-
1
votes1
answer56
viewsHow to improve QUERY
As I could improve this query, it returns me 30 records from a table that contains 43thousand records. NOTE: I use index in the core column (much improved). ((SELECT id,situation,info FROM request…
-
1
votes2
answers59
viewsQuery to add fields from two tables
I need a query where I will need to add people by color and race, distinctly, for example, make the sum not only by name, but also by color and race alike. I tried something below, but it’s adding…
-
1
votes1
answer222
viewsQuery SQL returns records only after 2 days prior to today
Guys, as I am new to SQL, I need a help. I need to bring only the records that have not been moving for more than two days. The query below is bringing everyone without this condition. I even ran a…
-
1
votes0
answers316
viewsHelp to optimize an index in mysql
I own a site of relationships and for years I try to optimize this query. Almost every day the site hangs because of it. Structure of the user table CREATE TABLE `usuarios` ( `id` bigint(20) NOT…
-
1
votes0
answers50
viewsSelect in varchar column containing only one word
How to run a SELECT SQL that only looks for VARCHAR type results that contain only one word? That is, I don’t want results with more than one word
-
1
votes1
answer69
viewsDoubt query - SQL Server 2012
Good afternoon! Guys, I don’t know if it’s possible, but I wanted to know how to get a record of a line in another line. I’ll illustrate. In the query below is coming out like this. Projeto…
-
1
votes1
answer426
viewsHow to find an xml tag information using xPath in Postgresql?
I wanted to use the remote xPath, but I’m not sure how it works. I have a table and inside it a column that stores XML's. I would like to conduct a consultation that brings the value that is within…
-
1
votes1
answer37
viewsDuplicity with JOIN
Hi, I need a hand, if you can help me, I appreciate. I need to query between three tables, however, when I search the query is returning me duplicate lines: SELECT US.NOME AS PROFISSIONAL,…
-
1
votes2
answers1525
viewsBrowse previous record - SQL Server 2012
I need to bring only the records where the previous status was 1, but which is currently 0. I have a table called solicitação containing a field called VencimentoPausado, where this field values are…
-
1
votes2
answers150
viewsQuery with JOIN in 3 tables
I have the following tables: livroautor id idautor idlivro ------ ------- --------- 1 1 (NULL) 2 2 2 3 3 3 4 4 4 5 5 5 6 6 (NULL) 7 7 5 8 8 2 9 9 2 10 10 (NULL) book id titulo resumo isbn paginas…
-
1
votes3
answers789
viewsProblem sorting sql with orderby Date in postgresql
I have the following query that results in the union of the total sum of an account and the installments select sum(total) as total, datavencimento from ( select sum (con_valoraserpago) as total,…
-
1
votes1
answer22
views -
1
votes3
answers211
viewsDelete duplicate records via php in mysql
Good morning guys, I read some articles here with similar problems, but none of them answered my question, what I want. Here’s the thing: I have a query to check which lines have a duplicate field…