Most voted "sql" questions
Structured Query Language (SQL) is a language to query databases. Questions should include examples of table code and structure. This tag refers to the default language, not to be used for questions about the implementation of specific DBMS (such as Mysql, Postgresql, Oracle, MS SQL Server). In this case use the specific DBMS tag. Answers to questions marked with ANSI SQL should use SQL as much as possible.
Learn more…6,771 questions
Sort by count of
-
0
votes1
answer62
viewsHow to insert a constant in a PL/SQL line?
Hello, I’m having some difficulties in data presentation. with atores(nome, data_nasc) as (select nome, data_nasc from representa inner join artistas using(n_artista)) ,realizadores(nome, data_nasc)…
-
0
votes1
answer154
viewsMYSQL - add column and calculate days late of a date and sort by the longest delay
Hello, Suppose I have a table tb_fatura with the following fields and values: id | transacao_id | valor | vencimento 1 | 1 | 1109.97 | 2020-02-19 2 | 1 | 10, | 2019-05-01 I want somar the column…
-
0
votes1
answer209
viewsConvert DATE in SQL (Oracle) from UTC to Brazilian time zone
I have the following query: SELECT c.name, t.sequential_id AS sequencialid, CONCAT(SUBSTR (REPLACE (m.content, '¿', ''), 0, 30), '...') AS content, m.direction, (CASE WHEN TRUNC("M"."DATE") =…
-
0
votes1
answer52
viewsSQL grouping
I need to select the following: 'SELECT TR.CODPARC, TR.NOMEPARC, TB.CODVEND, TV.APELIDO, TV.AD_CARTAOCAMP, TP.AD_CAMPLENTE, TP.AD_CAMPPONTOS FROM TGFCAB TB, TGFITE TE, TGFPRO TP, TGFPAR TR, TGFVEN…
-
0
votes1
answer318
viewsPHP - Login System
I am creating a login system and would like to know what is causing the errors Notice: Undefined variable: e in C: xampp htdocs login CLASSES usuarios.php on line 14 Fatal error: Uncaught Error:…
-
0
votes1
answer22
viewsProblem in queries N : N
I wonder why I can not search a query in tables that have the relationship N to N. I need to search the name of the product, the name of its manufacturer, the name and email of its suppliers, only…
-
0
votes1
answer40
viewsBring manager and employee who are on the same table
I have a table of EMPLOYEES and another call HIER_SAP. In the HIER_SAP I have two important fields for what I want, that are the fields CODSUP and CODFUNC. For each CODFUNC(official) I have a…
-
0
votes0
answers50
views -
0
votes1
answer36
viewsPercentage of each value within a table field. The field stores two values, 1 for yes and 2 for No
I’m trying to develop a customer satisfaction survey application where the user answers some questions with numbers 1 to 10 and another yes or no. In one of the reports, I show the average of each…
-
0
votes0
answers39
viewsError "Call to a Member Function query() on a non-object in"
Any idea what’s going wrong? What should I do to make it work properly? Thank you in advance for your attention !! Fatal error: Call to a Member Function query() on a non-object in C: Users....…
-
0
votes0
answers33
viewsEdatabaseerror "zqryList: Field 'Number' not found" when the alias contains "/"
There is a field in the SQL of my form with the alias "Number/Minuta", and when the SQL is executed for the second time the message Field 'Number' not found is fired. I can solve this by giving a…
-
0
votes2
answers295
viewsPerform SQL query with two foreign keys from the same table?
I’m creating a recognition system for the company and it was almost over, it’s been some time that I’m trying to carry out this consultation but not getting. I have the following tables:…
-
0
votes1
answer41
viewsSQL Server Order Allocation
It is possible for me to relocate this latest product with ID 21, to the field I have drawn in red? Actually, look at that. It is not by TOC, but something functional, in our site where it is taking…
-
0
votes0
answers38
viewsHow can I clone a record from a stored table using Procedure and picking up the fields dynamically?
I have the need to clone a record into a table but picking up the fields the way they are, the reason is that someone can insert or remove some column, so I don’t know which columns I have in the…
-
0
votes1
answer43
viewsProblem with SQL return
I have the following 3 tables: Clients, Requests, Requests: Customers: Solicitations: requeca_description The request table links to the client table(cliente_id = id[client table]) and linked to the…
-
0
votes1
answer45
viewsHow can I use sp_executesql to execute a query mounted on a variable?
I’m learning to use cursors and I’m trying to run a query I’ve mounted within a variable but it’s giving the following error: "Message 214, Level 16, Status 2, Procedure sp_executesql, Line 1…
-
0
votes0
answers224
viewsHow do I make an Insert into using dynamic SQL and run sp_executesql?
I am trying to make an Insert using cursor and execute sp_executesql using variable, the first time it ran and did not return anything, I went to the table and had not added any record. Then I ran…
-
0
votes0
answers80
viewsHow to return materials from a product or product levels with PL/SQL
I have a table that contains products and each product has other products that are used to manufacture. The products that are used to manufacture the parent product, can also be manufactured and…
-
0
votes0
answers25
viewsCollision when generating random number that is different from an already entered number
I have the following problem: It is necessary to assign a coupon number to a certain person after a purchase and it has the following conditions: it must have 6 digits, the first digit being the…
-
0
votes1
answer30
viewsHow do I get back the id of the new record created in a table using cursor and Procedure in SQL Server?
I’m trying to make my previous run and return the registration ID that has just been created, as I don’t have much knowledge of cursors and procedures I don’t know where I am failing. When I run the…
-
0
votes1
answer20
viewsImplementing view
Display statement of a particular account with the respective movements of a 15 days prior to the request date with the following data: Agency; Account number; Name of the account holder; Account…
-
0
votes0
answers146
viewsHow to group by column only when it is not null (Oracle)?
The query is summarized to facilitate: SELECT nome,idade,profissao,cidade, bairro, estado, pais FROM objeto group by nome,idade,profissao,cidade, bairro, estado, pais; However 3 columns can come…
-
0
votes1
answer48
viewsSelect in NODE returns empty
When I run this query: SELECT xml_nfe FROM NDD_COLD.COLD_PROD WHERE ide_id ='NFe42200602831172001104550000010390091233318028' In plsql it returns me a line with information, then I pass the same…
-
0
votes2
answers127
viewsSELECT LIST returns only one value and not a list
Hello, I have two tables, one representing the groups (Certification.certification_adm_email - columns start with "fall"), and the other users (admin.dbuser - columns start with "user"). Among them…
-
0
votes1
answer440
viewsCan I work with array in SQL SERVER?
Hello fellow collaborators... I have a server that has more than 100 banks, and most are of the same structure. I would like to create a function, process or whatever. That could expedite my…
-
0
votes1
answer45
viewsDoubt Mysql - Query result
Help me with a situation please, I need to get all the records of the table "buyer" and its attributes and if I have in the records of a client in the order table linked to some buyer listed it…
-
0
votes3
answers202
viewsWays to take only the month of the dates recorded in the database
I need to take only the months of the dates of a given field that is in my database, however, preferably without using SELECT MONTH. That way, we get the current month of today’s date: $mes_atual =…
-
0
votes1
answer48
viewsHow to look at the field that is being changed in a Procedure?
I created a precedent where after running or updating in a table the flag is marked S automatically, causing this item to go up to an integration and integration after the return of success mark the…
-
0
votes1
answer1009
viewsWarning: mysqli_connect(): (28000/1045): Access denied for user 'root'@'localhost'
I’m making a website, while testing locally this connection code worked <?php $servername = "localhost"; $database = "bdcomentarios"; $username = "root"; $password = ""; // Create connection…
-
0
votes1
answer85
viewsDivision of SUM() into SQL Developer
We are running the SELECT below in order to deliver a percentage difference between the somatic values PRECO_UNITION and PRECO_TABELA. We try to do this in the simplest way by performing the common…
-
0
votes2
answers147
viewsLoop - SQL Server
good afternoon. All right? I’m trying to print a loop of hours where Data10 should show start date + 10 seconds and Data5 should show start date + 5 minutes I tried the down loop without success:…
-
0
votes1
answer107
viewsRun a SELECT inside an IF in SQL?
I would like to know how to execute an IF condition with SELECT, I am still studying about SQL so in the example I will try to pass only the idea because the syntax will probably not be correct. IF…
-
0
votes1
answer112
viewsSQL - Count Distinct
I am trying to make the relationship of two tables: one of Customers and one of Refills. I have already created reload tracks, total amount of transactions, type of transaction (Reload or…
-
0
votes3
answers101
viewsDetermine when Loop WHILE should stop PHP
I have the following problem, I have a system in PHP that makes a WHILE in a column of the database that contains certain values and I need WHILE to stop at a value that I determine. The first…
-
0
votes1
answer282
viewsHow to make a cumulative sum in Bigquery?
Hello. I need to create a Dashboard from a query. I would like to generate this column in the query always adding up to the previous month, ie a cumulative sum. ex: instead of: mês 1: 2 mês 2: 3 mês…
-
0
votes1
answer92
viewsSelect Lotofácil games that must contain dozens of specific
I have a Mysql Database containing all combinations of Lotofácil, exemplified below: I am trying to recover, for example, the games that contain the tens 11, 17 and 21, obligatorily in the same…
-
0
votes1
answer58
viewsWhat should I put into parenthesis?
Hello I’m starting to program now and I was following a video lesson and following the teacher’s steps, however arrived in a part that he installed the sqlite, however his version was previous to…
-
0
votes2
answers62
viewsUnion of select’s to return only 1 query
We need to perform the following queries in only 1 select: 1st SELECT SELECT SUM(FAPEDIDO.TOTAL_PEDIDO) AS TOTAL_CAR, FAPEDIDO.CD_REPRESENTANT COD_REPRESENTANTE, GEEMPRES.NOME_COMPLETO REPRESENTANTE…
-
0
votes1
answer191
viewsWrite Oracle SQL File
Good morning, I am beginner in Oracle PL/SQL, and I created the script below to record the result of a query in txt file, runs without errors but does not write the file, anyone knows what could be…
-
0
votes1
answer47
viewsHow to convert UNIQUEIDENTIFIER to INT?
So quiet people? I’m beginner with SQL SERVER and I’m in a situation where I don’t know how to proceed anymore. I have 2 banks on a server here at the company, and I need to replicate some data that…
-
0
votes1
answer77
viewsIs my SQL code okay?
I’m learning SQL, and my teacher gave me an activity, I did it, but he gave me 1 grade. I want to know if the code is right. CREATE DATABASE escola; USE escola; CREATE TABLE aluno ( codigo INT…
-
0
votes0
answers112
viewsRegister Mariadb External Database Products on Woocommerce
Regards. The local system uses the database Mariadb, we know that there is Rest API Woocommerce, the question is whether there is a way to interconnect the databases Mariadb with Mysql Woocommerce…
-
0
votes2
answers790
viewsHow to get max() and min() data in SQL?
How can I get the minimum and maximum date of a table? I am using the functions min() and max(), but it is not returning the expected value. This is a small example of the date data from my table:…
-
0
votes1
answer288
viewsMysql: How to find string from a given character?
I’m developing a small system - and I’m not an expert on Mysql (so the doubt may be silly) I receive from the client a giant string with 580 characters - this string contains a series of information…
-
0
votes1
answer70
viewsAverage between dates
I’m learning SQL and I still have a lot to learn, but I’m trying to generate a report and I found some difficulties. I made that first consultation: /* Aqui estou selecionando as colunas e gerando a…
sqlasked 4 years, 3 months ago Getulio Barreto Rodrigues 19 -
0
votes1
answer73
viewsPython - Error: SQLCODE=-30082r] SQL30082N Security Processing failed with Reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001
Hello! I need help with the following problem: I made a script in python to collect data from a DB2 table and generate a spreadsheet. I’m in the testing phase, but the idea is that the script will…
-
0
votes1
answer115
viewscount amount of records in recent months
I have 3 aircraft tables, occurrence and aeronave_occurrence, I need to know if the same aircraft was present in any event in the last 2 months of the data_utc back, and how many aircraft were…
-
0
votes1
answer308
viewsCalculate Average Cost of a Stock Position
Hello, I’m trying to create a query that calculates for all dates the average cost of the action. The formula is described below. The Average Cost Price formula in T0 is: ((Accumulated Position T-1…
-
0
votes1
answer45
viewscounting records by time interval
I have 3 tables: aircraft(id_aeronvave, registration); occurrence(id_occurrence, data_utc); aeronave_occurrence(id_aeronave_occurrence, id_aircraft, id_occurrence) I have this list of aircraft by…
-
0
votes2
answers58
viewsError when registering.php with mysql (final step) "INSERT"
follows below the code of the register that I made. In thesis it is working perfectly, but at the end of the moment it is to give the INSERT, it ends up falling in LSE (ie, the registration was…