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
-
0
votes1
answer31
viewsQuery SQL Help
select T.n_acid,T.marca from (select n_acid, veic_seguro, marca from marca_acid as ma, veiculo as v where ma.veic_seguro = v.n_veic) as T group by T.n_acid, T.marca; This query returns the table…
-
0
votes0
answers22
viewsHelp on this select I need a clause to delete records
Good evening, I need to solve a problem in this consultation SELECT * FROM campanha WHERE limite > '0' AND tipo = '1' ORDER BY rand() LIMIT 1 I need to do the same query plus deleting all…
-
0
votes1
answer23
viewsTriggers for date verification
I’m having a question! I have a schedule of contracts and wanted to update the field of data_exclusao for the current date each time the field data_inicio is possible through triggers? I’m a…
-
0
votes1
answer94
viewsHow to add and store what were the added id?
Good afternoon, would like to know if it is possible to perform a query summing some values and create a column with the ids in which the values were summed. -- table 'value' | id | value | status |…
-
0
votes2
answers762
viewsHow to put ISNULL in Subselect with case?
How do I return instead Null return as Não. I’m having second thoughts about using the ISNULL within the Subselect along with the case. Upshot: Projeto teste Null Projeto OK Sim. Instead of Null I…
-
0
votes0
answers42
viewsError using MD5 in @Query in Springboot application
Good morning, initially I was trying to execute a query that would return a checksum: @Query(value = "SELECT MD5(STRING_AGG(atendimento::text, '')) FROM atendimento WHERE id_avaliador_fk = ?1;",…
-
0
votes1
answer39
viewsReturn query without record in the database
Hello. I have a PHP system with Mysql from a truck fleet company. In this system each user performs a Checklist of the vehicle before using it. This Checklist is registered in a table in the…
-
0
votes1
answer689
viewsLong to Varchar data conversion
I am trying to convert data from a Long field to Varchar, but when I do the procedure, it is returning the following error: ORA-01422: Exact extraction returns more than the requested number of…
-
0
votes0
answers46
viewsEmail search without domain
I’m doing a query to receive various data from BD, which includes entering the email field, but I don’t want to when doing searches to be shown emails because of the domain. For example, I have an…
-
0
votes1
answer71
viewsDisplay Mysql search results according to the sequence shown in the in clause
How do I sort the results of a query as a sequence displayed in the In clause? That is, the order of the lines must respect the same order of values indicated in this clause. Example: sql = select…
-
0
votes1
answer34
viewsPython - Problem with df.apply(Function)
beauty? Can I get a little help? Just call. I have a dataframe with some string information and wanted to change them to text. To simplify, imagine that the table contains information of the…
-
0
votes1
answer201
viewsSlow Query - SQL Server 2012
The query below is taking on average 30 seconds to execute. I know that very likely can be the various or and like, but I am searching from the log table and not always the id will be the same, why…
-
0
votes1
answer1541
viewsTo assign the value 0 to a query by returning NULL SQL
Good afternoon, I have a question regarding the treatment of values in a query. The query below to the executed returns a null value NULL as I could assign the value 0 instead of NULL? select…
-
0
votes2
answers44
viewsPersistent error in C# database
I was doing a project but there was a problem involving Oledbcommand occurring in two different places: dr_alu = _dataCommand.ExecuteReader(); if (dr_alu.HasRows == true) dr_reg_notas =…
-
0
votes1
answer70
viewsSET TIMEZONE in raw query
The raw query below shows the following error: query = Resume.objects.raw(""" SET TIMEZONE='America/Sao_Paulo'; SELECT id, datetime_now FROM resume; """) raise AssertionError("database connection…
-
0
votes1
answer53
viewsWhen modifying a data before sending to Query it updates the table
I’m doing a query select with spring + Hibernate, Query query = em.createNativeQuery(sqlBase); I am passing to the 'sqlBase' a Company as parameter, SELECT e.* FROM Empresa e WHERE e.id = :empresa…
-
0
votes1
answer675
viewsDivision of tables with Count and Sum
I am preparing a query where I have some sums and counts and, in some parts, I need to make a division in a table that I have added or made the count, for example: COUNT(M.ID_MAILING), SUM(CASE WHEN…
-
0
votes2
answers284
viewsSQL Oracle - Clob to Number
I have a table which does not have to be remodeled, it is composed by a CLOB field which has decimal values separated by point ex:(123.12) I need this field to be returned to me in the result as a…
-
0
votes1
answer136
views -
0
votes2
answers550
viewsSQL Server - Select last 7 days from the last record
Guys I’m beginner in SQL and it’s complicated to solve this problem that came up.. I need a select in SQL-Server that returns: the sales of the last seven days. For example if the last day there was…
-
0
votes1
answer23
viewsSQL-Obtain code of the employees who participated in all projects
I have the following tables Employee(Empnum ,Name) Project(Projnum,Name) and Assignment (Empnum ,Projnum,Function) I wanted to build a query in which I return the employee number (Empnum ) that…
-
0
votes0
answers66
viewsSyntax error in Informix database query
I made a prototype of a database informix in the Access to optimize the construction of my queries. I use with the Mysql and through some adaptations in the syntax I get a good. But in the…
-
0
votes1
answer343
viewsHow to add 1 second to an Oracle date?
I am trying to search a table for a row that has the start_date in the second after the date placed. select * from PAY_PERIOD where pay_period_schedule_id = 2 AND start_date = TO_DATE('2020-04-30…
-
0
votes1
answer1178
viewsWorking day function
The query below in datediff is bringing the difference of days correctly, but I just want to bring the amount of working days. I already have a business day function that excludes Saturdays, Sundays…
-
0
votes1
answer171
viewsError: FROM keyword not found where expected
I am trying to do the following Inner Join but am getting error: FROM keyword not found where expected select e.num_exame as [exame], a.num_amostra as [amostra], e.data_hora_exame as [exame],…
-
0
votes1
answer63
viewsHow to return a data even if the table has no data
I wonder if there is any way to return a value even if the result of the query is null, for example in the query below I try to return the id 0 case to table1 be it null. I tried to use CROSS JOIN…
-
0
votes2
answers33
viewsQuery SQL listing shopkeepers by id and status
Personal I have a table where I list purchases of customers, in this table I have information as the id of the shopkeeper and the status of the order, this status goes from 0 to 6, however I would…
-
0
votes1
answer304
viewsDoubt - SQL Server Dates
In the script below when one task is completed the other will open on the first working day of the following month. Example: Task 10 was completed on the day 18-11-2016, then another will be…
-
0
votes1
answer69
viewsMYSQL returns OK
Good evening friends, Can anyone tell me why the query below returns OK? SELECT Count(*) as Dias_uteis FROM Owner.dias_uteis d WHERE d.data_util BETWEEN (select ts.creatión from Owner.tabela ts…
-
0
votes1
answer180
viewsMongoerror: Unknown top level Operator: $expr
I’m trying to do this in my code and works perfectly on the localhost but on the Umbler server is giving error. FOLLOWS THE ERROR: MongoError: unknown top level operator: $expr Follow the code I’m…
-
0
votes1
answer33
viewsQuery Transformation
Does anyone know if it is possible to transfer a SQL SERVER query into a new table? No longer query to be shown with a "show table" command made from a query for example ?
-
0
votes1
answer37
viewsSingle line query result
My database is like this: id | municipio_id | ano | populacao 1 | 0 | 2010 | 5000 2 | 0 | 2011 | 5000 I have the following query: SELECT case when ano = 2010 then populacao end a2010, case when ano…
-
0
votes1
answer235
viewsUpdate with select CTE Error
I am having difficulties to perform an update with select CTE. I want to update the charging field. Below is the query and just below is the update I tried to perform, but the following error…
-
0
votes0
answers81
viewsChange Mysql query to work on SQL Server and Oracle
Would anyone know how this query in Mysql would look in SQL Server and Oracle? SELECT COUNT(*) AS TOTAL, SUM(EVENTO = 7 AND RESULTADO = 0) AS QTD_RX_OK, SUM(EVENTO = 7 AND RESULTADO <> 0) AS…
-
0
votes1
answer33
viewsMake a query with pymongo filtering by a string ignoring uppercase and minuscule letters
I need to make a query in a database in Mongodb using the pymongo library in python, the query I am making is as follows: dbCliente.find({"nome": "carlos"}) I want to return the client whose name is…
-
0
votes2
answers514
viewsQuery result null Firebase
Hello folks I’m having a problem to perform query in firebase database. This is the bank: I’m trying to carry out a search of all the restaurants that have the name Iguatemi, until then according to…
-
0
votes1
answer30
viewsMy Sql, query with two different parameters for the same column to bring two different results
I have a situation that I need to calculate the total number of rooms over 50 meters, then I need to calculate those over 100 meters, and so on. Is there a way I can do it in the same query? I need…
-
0
votes0
answers24
viewsFix with select using sum within case
I’m trying to use the code below: select case when((sum(valido) / sum(total) * 100) >= 60 then 60 else (sum(valido) / sum(total) * 100) end) i1 from tabela Syntax error near 'then 60 Else...'…
-
0
votes0
answers51
viewsGenerate sql script on a given date
Good afternoon! Guys, I have a big mission here. I have a script that I assembled below that I need it to be executed only on the 1st of each month respecting the two conditions I put in the IF…
-
0
votes0
answers7
viewsHow to make @Query queries in Manytoone relationships
People would like to know one thing. I am doing a project with jpa/Hibernate and in the mapping of my classes they are all @Manytoone. I have to make an sql query with two Join in series. When I do…
-
0
votes1
answer28
viewsUse more than one value to use parameter in an Oracle function
Good afternoon, I have the following problem: I need to perform a function that calculates the average value of a product on a specific date. SELECT VERIF_VL_CUSTO_MEDIO(PRODUCT.CD_PRODUTO,…
-
0
votes1
answer30
viewsQuery does not return setted WHERE
I am trying to perform a query to the Informix Database, and it is bringing the data in normally, but it is ignoring the search criteria. SELECT cnnfcapa.id_nfcapa, cnnfcapa.filial,…
-
0
votes0
answers52
viewsSubquery in Informix Bank
I have an appointment that seeks sales of a period: SELECT cxpdvend.filial, cxpdvend.dtpedido, cxpdvend.pedvenda, ciendere.nro_endere, cipessoa.nomepessoa, ciendere.celular, cxpdvend.codagente,…
-
0
votes2
answers513
viewsCriteria for consultation with a wildcard character
I am trying to use wildcard character as query criterion in my query, however the result is returned empty. include_once(".. /inc/conexion.php"); $lj = "4"; $linha =…
-
0
votes0
answers67
viewsPostgresql compare time between two hours, and if it exceeds the hours of the day, limit up to 23:59
I’m making a query sql in the ruby-on-rails for PostgreSQL where I check if the user input is between hora_entrada and hora_entrada + (hora_entrada + limite_banco_horas) and the same goes for…
-
0
votes1
answer543
viewsFPDF with Mysql and PHP - Bringing Repeated Data
I’m trying to set up a generator system Vouchers/Tickets I have a table in SQL with the name Vouchers with multiple users and their respective passwords. I call in each Cell the variable…
-
0
votes1
answer711
viewsCheck the frequency of records in the table
I have a table where are saved all services performed in several cars. The key is the car plate. A car can have more than one service performed per day. And for each service performed a new service…
-
0
votes1
answer60
viewsDoubt SQL query via primary key in PHP?
I am starting in the PHP language, and need to return a simple query made in sql from a variable that receives the value typed by the user. Since, it will only display the primary key search result.…
-
0
votes2
answers120
viewsRemove repetitions in select Oracle sequence
I have a question to mount a query on Oracle, I have the following so far... SELECT M5.NIVEL_ESTRUTURA , M5.GRUPO_ESTRUTURA , M5.SUBGRU_ESTRUTURA , M5.ITEM_ESTRUTURA , M5.SEQ_OPERACAO ,…
-
0
votes1
answer48
viewsConsulting cities without repetition and with different "WHERE"
When trying to resolve a platform bank issue hackerrank I could not understand the answer after having found in the discussion wing. The question says: Query a list of CITY Names from STATION with…