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
votes2
answers39
viewsShow data set with SELECT
Opa, then, I have a problem to find (show) some data that is being requested, I need to show the following data: https://i.stack.Imgur.com/ypczD.png and always appears the error that is an ambiguous…
-
0
votes2
answers58
viewsImport Excel data to table in SQL Server (only data other than that already in the table)
I just want to add different records than the ones already in the table, that is, they would only be records from Idcollaborator 10.…
-
0
votes1
answer181
viewsCheck if websites are working, php
Hi, I’m wanting to do a check on several links, check if they are working, I’m using the code below for this, but it only works when I test locally on the server of my pc, when I raise it to the…
-
0
votes0
answers12
viewsWhat is the difference between floor and trunc in sql oracle?
Studying SQL with Oracle I came across floor and trunc, apparently both have the same function, which is to round the decimal numbers down. I would like to know if there is any difference between…
-
0
votes1
answer25
viewsDifficulty in dynamizing columns in MSSQL
Gentlemen, good morning ! I’m having a little trouble building this query in Microsoft SQL 2019 Could someone maybe give me a light ? I have a base like this Codfuncionario | cod_centro_custo |…
-
0
votes0
answers47
views"SQL syntax error" FROM NOTHING after 1 year running
For 1 year the software of my company worked if problems, until on a beautiful day of nothing happens it (is giving us a lot of headache and cost): PHP Fatal error: Uncaught exception 'PDOException'…
-
0
votes1
answer142
viewsCumulative count per month
I’m having difficulty making a cumulative count in mysql. I need to count the amount of active registration accumulated in each month. Table: id | data_cadastro | data_exclusao…
-
0
votes1
answer49
viewsMysql event does not run at specified time
I created an event in mysql so that every day on time 00:05:00 Starting on 07/18/2021, it performs an update on a table, only it is not running at the given time, what might be happening? Follow the…
-
0
votes2
answers517
viewsSelection top 3 Where distinct
Good afternoon, you guys. https://stackoverflow.com/questions/1925176/sql-server-2008-top-10-and-distinct-together I need a help, I tried to see in the above section but could not solve my problem.…
-
0
votes0
answers40
viewsWhat is the function of the Unique Switch in foreign keys?
If the foreign key will always reference a primary key, which by definition is unique, then what is the need to define the Unique Constraint in foreign keys?
-
0
votes0
answers13
viewsIt is possible to pivot with varied values to turn into column - SQL
Hello! I am studying sql, and I am doubtful, I am with a sample bank, and I have the following situation, I have a product code, and an Ean code in products, for Ean code it repeats the product…
-
0
votes2
answers105
viewsAdd FK in mysql table
Good morning I am facing the following problem, I created 2 tables in the bank, while trying to create a fk in one of them generated the following error:#1215 - Cannot add Foreign key Constraint.…
-
0
votes0
answers534
viewsQuery error - Inconsistent NCLOB data
Hello, I am trying to perform a query in an Oracle database and is returning an error ORA-00932: inconsistent data types: expected - obtained NCLOB 00932. 00000 - "inconsistent datatypes: expected…
-
0
votes1
answer23
viewsDoubt to return a query
I have the following problem, in sql server I have a table of contracts and one of clients where returns as follows: In Where condition I need to pick up only the last created id of each customer’s…
-
0
votes1
answer30
viewsUnexpected end of random command in Firebird
I’m having a problem in the system I develop, for some reason I get the message: Unexpected end of command - line 1, column 214 But I can’t find which SQL the problem is occurring. From what I found…
-
0
votes0
answers68
viewsSQL Management Studio only connects remotely without the instance
While trying to make a connection with a first remote SQL, I realized that my Management Studio could not connect using the instance, as follows: After that attempt, I removed the instance, and…
-
0
votes1
answer422
viewsSQL Server 2017 - Recover column description/comment in table in database - Metadata
I am trying to generate a data dictionary of my database in SQL Server 2017, and would like to recover the description/comment of the 'Description' field contained in the column definitions of each…
-
0
votes1
answer111
viewsSQL Server 2017 - SELECT with Duplicate Metadata
I made a select using metadata, but the result of my selection brought me something like 'Cross Join'. Even using GROUP BY and DISTINCT returns with duplicate values. I would like an help to return…
-
0
votes1
answer28
viewsOracle Year in full
This question is allowed ? Simple , in thesis SELECT TO_CHAR(SYSDATE, 'YEAR','NLS_DATE_LANGUAGE=PORTUGUESE') FROM DUAL; You should return Two thousand and twenty-one. But returns TWENTY-TWENTY-ONE…
-
0
votes0
answers14
viewsRemote database access c# with SQL server
Personal greetings I have a c# application using the SQL server database I would like to know, after configuring SQL server for remote access What connection string can I use for on the client…
-
0
votes1
answer254
viewsIs it possible to filter through a calculated column?
Gentlemen(s), I am performing the following select on my database. SELECT TOP 5 A.APELIDO, A.REALIZADO, A.META, CAST((A.REALIZADO/A.META)*100 AS DECIMAL(10)) AS ACUMULADO, DENSE_RANK() OVER (ORDER…
-
0
votes0
answers24
viewsHow to read an entire SQL Server table and update another one?
I need to do a massive daily processing where I need to read a table my row by row and apply some rules and in the end update a column from another table. What would be the best way to make this…
-
0
votes1
answer47
viewsHelp in showing data saved in a database on a php page
So guys, I’m starting now to learn how to mess with php and I’m trying to make a registration system whose will be registering in it activity. I’ve already got a lot of stuff, I was able to connect…
-
0
votes1
answer78
viewsColumn ambiguous
I have a problem with the code that I can’t understand. The postgres always points to the error _"column Reference "pro_codigo" is ambiguous"_, but I gave the proper "nicknames" to column…
-
0
votes1
answer226
viewsHow to fill out combobox with SQL query? C#
I wonder if it is possible to pass data from an SQL query to a combobox using C#. I researched the subject and found examples, but when I adapted to my case , I could not use. I am doing this way:…
-
0
votes2
answers4117
viewsSQL how do I enter into a table that has FK?
How do I make a insert into in a table where there is a FK? example this is my structure Pessoa ID (primary key) nome varchar(20) id_endereco int not null (foreign key)…
-
0
votes2
answers33
viewsDoubt in the insertion of data performing the relationship in another table
I am trying to enter an Address in the address table and refer to a User already registered without Address in the user table, through the _id that is generated when I enter an Address. I return…
-
0
votes1
answer54
viewsLIKE with explodes PDO
Good night consecrated, I have a search page, in which I want that when someone searches something like "i3 memory screen cabinet" appear all the items available in the table with respect to these…
-
0
votes1
answer161
viewsFilter with SQL query from a combobox - c#
I am creating a stock program and I would like the item query to be filtered by a combobox, that is, when writing in the search field only the results related to the combobox parameter appear. This…
-
0
votes1
answer48
viewsSearch without special SQL characters
I need to do a search with SELECT, but the title is not displayed, because some calls that are opened comes with special characters. Can someone help me? I use this command to search in the bank:…
sqlasked 6 years, 1 month ago ALAN BERTOLDO OLIVEIRA 11 -
0
votes1
answer274
viewsField for numbering or ranking distinct records - Oracle
I have a problem which is this:: Knowing that a care can have several exams, I need to number the exams in order to know the first, second, third..., for each service. Example: LINHA ATENDIMENTO…
-
0
votes1
answer1396
viewsconvert varchar to date oracle plsql
I need to convert a varchar for date so that you can filter all dates longer than a certain date, for example: I want all dates that are larger than November 2018 to be listed, I am doing as…
-
0
votes2
answers876
viewsCase in Sub Select SQL SERVER
Good afternoon, I’m having trouble making a case in a subquery. I need to bring information called id_request table sf_vendas_boleto, but when it comes NULL I need to bring the id_request table…
-
0
votes2
answers160
viewsHow to get the difference in seconds with Sql Server
I know that to get the difference of seconds between Beginning and End is like this: Case 1: DECLARE @TB_DIFERENCA_INICIO_FIM as table ( ID int, DataInicio datetime, DataFim datetime ) INSERT INTO…
-
0
votes1
answer47
viewsError: More than one value was returned by a subquery
Could help me identify the mistake: SELECT Failed. 3669: More than one value was returned by a subquery. SELECT (SELECT ID_FUNC FROM P_ISIDB.TB_DIM_FUNCIONARIO INNER JOIN P_ISIDB.TB_STG_VNDA ON…
-
0
votes2
answers811
views"Illegal string offset" error when calling usort in database data
I am trying to sort the result by a specific column of a database array. function cmp($a, $b) { return strcmp($a['usu_codigo'], $b['usu_codigo']); }; usort($usu_info_coluna, "cmp"); Giving a…
-
0
votes1
answer180
viewsI have a question in the kivy + sql text_input
Hello, I am trying to make a registration page and I am doing some tests in this code, for example, I am trying to make when I insert a name in the user field and press enter save this data in SQL,…
-
0
votes1
answer469
viewsforeach inside the foreach without repeating the data
I have a list of Employees and each employee can have many Cost Centers. And when I bring the bank employee information I need to list the cost centers and list the cost centers where the employee…
-
0
votes1
answer98
viewsMount Query with JOINS
I have a query executed on DB2: SELECT f.* FROM Fat f INNER EFat ef ON f.id = ef.id AND f.seq = ef.seq How do I reverse it in Java? I tried this way, but it’s wrong, all my classes are with their…
-
0
votes3
answers48
viewscompare sql tables displaying different result
I have an sql query that lists two tables: register and release. I have an application that adds the "id" of "registration" in the "release" table, i intend to display only the results that DO NOT…
-
0
votes1
answer29
viewsTanning system with Stored Procedure
I’m trying to make a stored Precedent for a simple likes system, my table is organized like this: Likes id INT(11) - Auto Increment post INT(11) - foreign key (id - post) user INT(11) - foreign key…
-
0
votes1
answer293
viewsPython Error SQLACHEMY
Is giving an error when I try to connect to SQL SERVER database with SQLALCHEMY from sqlalchemy import create_engine, engine import pandas as pd engine =…
-
0
votes1
answer44
viewsBring data from range
I would like to bring even those where there was value in the consultation For example; table dice id | valor | data 1 | 5 | 01/10/2018 2 | 6 | 03/10/2018 3 | 7 | 04/10/2018 5 | 8 | 05/10/2018 I’d…
-
0
votes1
answer191
viewsHow do PHP read Mysql from the bottom up?
My code is this: //Receber o número da página $pagina_atual = filter_input(INPUT_GET,'pagina', FILTER_SANITIZE_NUMBER_INT); $pagina = (!empty($pagina_atual)) ? $pagina_atual : 1; //Setar a…
-
0
votes1
answer183
viewsHow to resolve: Column "id" not found [42122-197]?
Guys, I’m creating an API that will display random phrases from a table in the database. The problem is that whenever I access the route, on the console, I get this exception:…
-
0
votes2
answers48
viewsPerform multiple operations in a single SQL code
I have a table in Mysql as follows and structure: I would like to run an SQL query that does the following operations: Total number of records (total1); Count how many records have id_nps_answer…
-
0
votes1
answer159
viewsJPQL JPA - Create a list grouped by date with the sum and profit of all items sold that day
The SQL query below is returning a wrong result to the fieldEntrega. SELECT DATE(p.dt_pedido) AS barChartLabels, COUNT( DISTINCT p.id) AS qtdPedido, SUM((item.quantidade * item.preco) *…
-
0
votes1
answer420
viewsJOIN 3 tables (LEFT JOIN)
I have a question regarding the best way (concerning performance and execution) to make the following select... Initially I thought of using LEFT JOIN, but I came across some restrictions on its…
-
0
votes2
answers44
viewsQuery syntax error with RFID code filter
Syntax SQL error on the part from estoque where cod_rfid = 102. Note: 102 is the value that is in the RFID tag. String dadoRFID = new String(readBuffer); String Del_inc = dadoRFID.substring(0,1);…
-
0
votes2
answers85
viewsError saving converted date in phpMyAdmin database
I am trying to write a form in the database, in this form has a date field that contains mask dd/mm/aaaa. To record in the bank I need to convert that date to aaaa-mm-dd, so far I’ve managed…