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
answer35
viewsUse of Count() for data recurrences
I have the following appointment: SELECT "metas"."Segmento", "metas"."Perfil", "metas"."Meta", "Negócios"."Nome" FROM "metas" JOIN "Negócios" ON "Negócios"."Perfil" = "metas"."Perfil" AND…
sqlasked 4 years ago Vitor Ceolin 464 -
0
votes0
answers11
viewsWhat is the conceptual difference between OLAP and OLTP?
Good afternoon, everybody, all right? What is the conceptual difference between OLTP and OLAP? Contextualizing: I am starting my studies in data analysis and I am with a doubt that I could not…
-
0
votes0
answers110
viewsHow can I correct the error in the query? [URI 2992 Higher Average Wage Divisions]
25% URI error. Why is the query not ordering? My query: select distinct on (de.nome) de.nome as name_dep, di.nome as name_div, coalesce(round(avg(ve.valor), 2) , 0) as avg_salary from departamento…
-
0
votes0
answers56
viewsHow to create a table with Crosstab in Postgresql?
I have a table tbexame and I want to create another one from a Crosstab, while studying I did the installation of the extension but I am not able to create a select so as to leave the result as…
-
0
votes0
answers68
viewsHow to compare SUM with another numeric field?
Good afternoon, I have a table SB2010 where I have the current quantity of product in stock and have the table SB8010 where I have the quantity of the product separated by lots. I need to verify if…
-
0
votes1
answer36
viewsSQL - doubt in query
I have the following appointment to do, I was able to think of them separately. I’m starting to study databases and I don’t know how to relate the two. Table Occurrence number, date, description,…
-
0
votes1
answer24
viewsHow to create a read sequence in a Select field in the Oracle Database?
I have a problem in my code I would like a help with an excerpt of my code. the ITE.SEQUENCIA line did not want to leave the number 1 fixed, because it may be that an item is deleted and starts with…
-
0
votes1
answer1304
viewspyodbc.Interfaceerror: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Name of data source not found
I am creating a code to perform an adjustment in a sql server database, but when trying to run it is returning error: pyodbc.Interfaceerror: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Name…
-
0
votes1
answer43
viewsIs it possible to use the return of a query with GROUP_CONCAT in the WHERE clause?
I need to make a query that looks for the type of visibility that the user has, and then search for all the other users that he "sees". The user can see all the users of the company, himself and one…
-
0
votes1
answer39
viewsgroup each period per month
I’m doing this consultation, but I’m not able to group each period per month, the previous year. For each month of the year preceding the current year, return the amount of parked cars per period…
-
0
votes1
answer73
viewsDoubt with LEFT or INNER JOIN and WHERE SQL Access
all right? So, I have this query here in Access: SELECT tbl_produtos.NomeProduto, tbl_produtos.PrecoVenda, tbl_precos_especiais.PrecoVenda FROM tbl_produtos LEFT JOIN tbl_precos_especiais ON…
-
0
votes0
answers22
viewsSelect comparing in Where 2 columns of different tables
I’m trying to set up a consult but it’s not bringing anything. SELECT EMP, COD, VEV, SEQ, TIP, NUM, EMI, VEN, DTR, GRU, PRO, QTD, PVE, TOT, FAT, COM, COO, REF, VAR, hcli.NOM as "VENDEDOR", hemp.enc…
sqlasked 3 years, 11 months ago Fernando Fefu 301 -
0
votes0
answers41
viewsERROR 1136 PROCEDURES + INSERT + FOREIGN KEY
This error is appearing and I am not managing to solve it: ERROR 1136 PROCEDURES + INSERT + FOREIGN KEY The number of parameters is equal. Did I do something wrong on constraint? Follows the Code:…
-
0
votes1
answer30
viewsResult for a Mysql query
I have this query in Mysql: SELECT usuarios.modalidade, produtos.idproduto, produtos.nome, produtos.referencia, produtos.ean, produtos.valorvenda, produtos.quantidadeprodutos.minimo,…
-
0
votes1
answer19
viewsDetermining the top-20 in a given year from a last.fm scrobbles table
Good afternoon! I created a table in a Mariadb test base (XAMPP) to store all my scrobbles (times I listened to some music) from the site Last.FM. I used that tool to generate the CSV and imported…
-
0
votes0
answers60
viewsAdd values to a PL/SQL cursor
Good night. I am trying to define the values of a cursor in PL/SQL, however one of the values is never filled. In this case, the qtd_daysSummary number never has content, however all others do,…
-
0
votes2
answers93
viewsHow do I get as much and as little as possible of a consult?
I have the following consultation: select DATEDIFF("D",DtVencimento,DtBaixa) as atraso from Entrada where Id='1' and DtEmissao >='01/01/2020' and DtEmissao <='01/12/2020' and ((VlBaixado is…
-
0
votes0
answers14
viewsJoin information from two tables into one for sql view
I have 2 tables, one contains the number of links of all my clients, in another I have the spreadsheet that contains all the registered calls of 1 of my clients, registered by several analysts.…
sqlasked 3 years, 11 months ago Selminha Barros 1 -
0
votes1
answer42
viewssqldatetime overflow c# When trying to use type = Date in Razor Using . NET MVC
When trying to save a change from a client, the SQL Server database is returning the following message: Sqldatetime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. View:…
-
0
votes1
answer51
viewsConcatenate values with condition (case)
Good evening! I’m new to the programming. I have the code below in a CTE that counts the number of subscribers in each area. In the main consultation I see which area has the largest amount of…
-
0
votes2
answers58
viewsSQL - Use Where value in another Where
Hello I’m not a programmer, just a curious developing a basic company system reports. I wonder if I can use the values of a Where (invoiced bills) in another Where (orders made). I am grouping the…
sqlasked 3 years, 11 months ago Marcelo Vinicius 1 -
0
votes0
answers69
viewsHow can I bring in a select a date range of a period in the oracle database?
Good morning, everyone, I have a question but I wanted to know if it is possible to make such action. I have a table with two date fields, start date and end date, I was wondering if it has how to…
-
0
votes1
answer30
viewsCan I not use a Trigger correctly in MYSQL?
delimiter // CREATE TRIGGER inventory_update_purchases AFTER INSERT ON purchases FOR EACH ROW BEGIN UPDATE products SET products.inventory = products.inventory + NEW.inventory_bought WHERE…
-
0
votes1
answer57
viewsSubselect and concatenate the same Oracle column result
I’m with that query, without the subselect she returns to me: Cod_atendimento | cod_agrupamento| cod_material 11223. 2. 200 11223. 2. 300 Result I’m trying to: Cod_atendimento | cod_agrupamento|…
-
0
votes1
answer58
views -
0
votes1
answer69
viewsView SQL database data in a similar way to the Access database
Good afternoon gentlemen I am a layman in the subject of SQL database and I am trying to visualize the data of an SQL database in table form, below is the name database E3 already created being…
-
0
votes2
answers63
viewsHow to select CNPJ higher billing? - SQL -
Hello, everybody! I have a table of customers with Grupo Economico code and CNPJ, each economic group has more than one record, and I cross-checked with my Billing and Address table, so far so good.…
-
0
votes0
answers29
viewsHow to access the value of an array within a while loop in SQL?
In the database I’m working on there are a number of salary variables that are registered as strings with entries like 0000001155,00. I’m using a combination of CAST and REPLACE to turn these…
-
0
votes0
answers23
viewsPredicate with a list of 2 values matching pairs
Hello, everyone. I have an SQL with filter that the user has the possibility to inform several "cost centers" and "cost sub-centers" combined. That is, in practice, it would be a list with 2 values…
-
0
votes0
answers28
viewsSelect with field of the same name between two tables without connection however approximate values
I have the 3 tables, 'users_teste', 'nps' and 'product', the product table has no relation with the other 2 tables, I need to perform a search comparing the request of the table 'nps' with the…
-
0
votes0
answers29
viewsProblem with validation process
I am creating a precedent to validate whether the field discount (%) receives a percentage less than zero (negative value) or greater than 100%. But when executing appears an error that I am not…
-
0
votes2
answers59
viewsHow to make a SELECT to get the value of the last registered date
Hello, I would like a help to always use the value of a table. I have a table "COSTS" and every month it suffers price change of the products, but are not all that has update My question is that…
-
0
votes0
answers37
viewsBank consultation does not match
I want to use the agenda table to manage the ranking with php when displaying so it would be simpler and practical because the user add the game in the table, when it starts the game already caught…
-
0
votes1
answer17
viewsHow to Create XML Array in SQL
I have the following XML structure <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gen="http://www.rapidaocometa.com.br/GenPoWMS10In"…
-
0
votes0
answers204
viewsORA-00933 SQL command not closed properly
Hello, good afternoon I am trying to run the following select on TOAD, but the error is occurring: ORA-00933 SQL command not closed properly SELECT ROWID, ECM_WF_PROC.IDWF_PROC,…
-
0
votes1
answer61
viewsC# LINQ Join with OR condition?
I need to write this SQL in Linq, but in that condition JOIN is what gets me. SELECT * FROM Boleto_Retorno AS BR LEFT JOIN Recebimentos AS R ON SUBSTRING(BR.CH_NossoNumero,1,11) = CASE WHEN…
-
0
votes0
answers57
viewsSQL Select INNER JOIN table contacts join all phones in single related record
I am facing the following dilemma: I have 3 tables (Supplier, Representative and Contacts). And the following query: select * from Fornecedor F inner join Representante R as on R.id_provider = F.id…
-
0
votes1
answer97
viewsSQL: Sort List by Vote Numbers from Another Table
I want the results of my poll to be sorted by the amount of votes you have in the other exclusive table to compute votes. Currently my results come out like this: I have two tables, this one below…
-
0
votes0
answers29
viewsON DELETE SET DEFAULT does not work in Postgresql?
I’m trying to leave the value default 'SEM CURSO' in the student table when the course is deleted, but the way I am doing the value of the foreign key is not getting default and yes NULL. I am doing…
-
0
votes1
answer47
viewsUse of multiple conditionals in an SQL query
I’m wondering how to perform a query with different conditionals. The query is a login validation, I need to check if the data contained in the user input is equal to the username or email or Cpf…
-
0
votes1
answer87
viewsC# and MS SQL Server Special Characters
I have a table of municipalities within the system, MS SQL Server database, and the names of municipalities are accented. I am consuming an API where municipalities come without any accentuation, so…
-
0
votes1
answer27
viewsPL/SQL Return specific value of a variable string
I need to separate specific information from a string within a field, in case only the value "refDate:dd:mon:yy", but the string varies in each record. How could it bring about the desired result?…
-
0
votes1
answer40
viewsExecute query by pressing a button and send to modal
I have the following code where I want to click a button, and in doing so run a Query and display the results in a Modal Therefore, the button: <a class="btn-sm btn-success view_data"…
-
0
votes1
answer64
viewsCrossing a primary key with 2 foreign keys from the same table?
I was studying some SQL and came across the following problem: I have 2 tables one called Order and another Locations, follow the fields below: ORDER id | data_creation | id_origin | id_destination…
-
0
votes0
answers23
viewsBring only one record in a left Join even if there are more records in the relationship
Hello, how are you? This is my query: SELECT cf.id_clifor, cf.nome, lv.localvenda, ed.cidade, ctt.telefone, cf.descontoglobal, lv.id_localvenda FROM ((tbl_clientes_fornecedores AS cf INNER JOIN…
-
0
votes0
answers45
viewsHow to filter a select result based on data contained in another table?
Good afternoon, Folks! I’m having a hard time building a select that is filtered based on a data contained in another table. To contextualize: It is a warehouse management system (WMS) and need to…
-
0
votes0
answers8
viewsMysql 5.6.12 - How to create date field with current default value
I am creating a table that has a separate date and time field (yes, the two separate fields), and in these I want the default value to be the current date/time. I tried to create the field with…
-
0
votes2
answers54
viewsHow do I select some lines of different audiences?
I need to select an audience within some constraints. The first 3 lines of the GRUPO 1 The first line of GRUPO 3 In case you don’t have first line on GRUPO 3: The first line of GRUPO 4 The first…
sqlasked 3 years, 9 months ago Juliana Miquelin 11 -
0
votes0
answers32
viewsDo you have a system to select profile equal to Netflix with different bank?
I created a table in the database with the parent user data, the one who created the account, and created a table that specifies only the child profiles, the ones that are added for each person.…
-
0
votes0
answers29
viewsImport Simple File by SQL Server Magement Studio giving Expired Run Time Out error
Hello. I am using the "Import Simple File" wizard from SQL Server Magement Studio to import a 2GB TXT file into a SQL Server Express database. I follow the entire process of the wizard, it…