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
answers216
viewsFilter objects in DJANGO - published_date__lte
I’m following a tutorial for modeling a BLOG through the DJANGO . In one of the processes, I create an object with the site posts and order them through the publication date: def post_list(request):…
-
0
votes0
answers311
viewsImport data from xlsx file to SQL Server
Hello, I am creating a SP to export data from a spreadsheet in xlsx format (Excel ), however I am not succeeding. My SQL SERVER is an older version of SQL Server 2000 (Build Version 8.00.2187), and…
-
0
votes1
answer61
viewsAdd result from POINTS column
Good afternoon! I have the following situation: I have a table with the results of some football games. I managed to assemble a SELECT and assign 3 points to the winner and 1 points to the draws.…
-
0
votes1
answer51
viewsSet primary keys in sequence
I have the table empresas as an example: cod | nome ----|---------- 3 | Asterix 7 | Lunar 13 | Coimbra Fortunately the table of companies currently has no reference in another table, I would like to…
-
0
votes2
answers697
viewsProblem renaming column in Sql Server table
I needed to rename a column from a table in Sql Server and used the stored SP_RENAME system processor. I used it as follows: USE [meu_db] GO EXEC sp_rename '[dbo].[minhaTabela].[minhaColunaAntiga]',…
-
0
votes2
answers231
viewsDifference between Mysql queries - Delphi
Good afternoon, I’m doing routine to close the inventory both in SPED and Sintegra, but is giving difference in the sum of the two. I’m using date as reference 31/12/2018. I’m using the same query…
-
0
votes2
answers625
viewsMake Calculations in Sql Server Database
I am making an application with Sql Server database and I want the database to work the calculations and not the application, but I’m having difficulties to do, I hope someone can help me in this…
sqlasked 5 years, 9 months ago Marcelo CL 21 -
0
votes1
answer136
viewsHow to check different data and get the first SQL record?
I need to create a filter in SQL that follows some rules, I have a spreadsheet in Excel and in it I need to apply the following filter, the spreadsheet has the fields: GSM MOTIVO_ENVIO DATA_ATIVACAO…
-
0
votes2
answers147
viewsTake duplicity by ignoring a column with distinct information
I searched here and found nothing like it. When I make the following Select : SELECT a.idEmpregadoReserva as Controle ,(select EmpresaAplicativo from tbEmpresaAplicativo where…
-
0
votes1
answer54
viewsLaravel Query Builder - problem with two Join
Currently I have a query that takes the posts and searches through Join some user data $posts = \App\Post::join('users', 'users.id', '=', 'posts.author_id') ->select('posts.id', 'posts.title',…
-
0
votes2
answers766
views2 Foreign keys in the same key
good afternoon! I am doing a Database exercise and came across a problem. I am registering a BD of an airline company. In one of the tables called flight need to register the code of an airport of…
-
0
votes0
answers58
viewsAngular API folder (how to mount this project?)
I took this project from a tutorial. The porblema is that it does not clarify where I have to put the folder "api" inside the Angular CLI project is giving error and the sql connection does not…
-
0
votes1
answer88
viewsFilter empty or null value in JSP file using SQL
Good afternoon, I have an SQL query as code below where I have 3 filters, these filters use the clause Where, and e and but if one of the filters is blank the value returned is also blank. How can I…
-
0
votes1
answer128
viewsIdentify the reference column of an Oracle virtual column
I have an index on Oracle in which one of the columns is DESC. I create it as follows: CREATE INDEX XFT25TB ON FT25T (FT07CODEMP, FI16MODELO, FT07CODIGO, FT25ORDIMP, DESC) However, when using…
-
0
votes1
answer43
viewsHow to Optimize Substring Regular Expression in Oracle BD
I have the following expression: SELECT us.FULL_NAME, us.USER_ID FROM knta_users us WHERE USER_ID IN(SELECT DISTINCT REGEXP_SUBSTR(PRJ.PRJ_PROJECT_MANAGER_USER_ID, '[^#@#]+', 1, LEVEL) AS GP_ID FROM…
-
0
votes1
answer28
viewsSum of values in Mysql
Good evening. I have to add the natures according to each sector of the company, but it is not going with Count. SQL: SELECT examefuncionario.exameFunc_Natureza, setor.setor_Nome FROM `funcionario`…
-
0
votes1
answer68
viewsDELETE statement does not delete by php but by phpmyadmin the instruction works
I have the following code where I am trying to delete a column from the comic through php : session_start(); $dbh = new PDO('mysql:host=localhost;dbname=samsic', 'root', ''); $sql =…
-
0
votes0
answers72
viewsI can’t run Precedent in PHP - Fatal Error on the execute line( )
I cannot run a precedent by PHP, at the time of sending the PDO execute displays the image error, in my base oracle the Procedure runs normally. I tried to make it display the SQL error but failed…
-
0
votes1
answer62
viewsHow to pass checkbox data through FILTER_SANITIZE in PHP?
I’m not getting past the values of checkbox in PHP. I have a single file home.php with the following code: <?php session_start(); ob_start(); include_once("conexao.php"); $btnCadastrar =…
-
0
votes3
answers70
viewsSQL with two different information
I have two queries in the database that work independently, but now the need to join them in a single script. I made some attempts, but without success. Who can help me, I would very much…
-
0
votes1
answer179
viewsExport Postgre SQL table to text (csv) via psycopg2
I am trying to export a table from the Postgres database to a txt (csv) file via Python, via psycopg2. However, I am encountering an error. The code is as follows (I switched login information to…
-
0
votes1
answer311
viewsData Passing from an SQL Query to an HTML Table
I am developing a code and the section related to displaying the data that is in SQL for HTML Table are not working. In this case I created a function in my DAO with the SQL query and passed to a…
-
0
votes1
answer34
viewsError handling of special characters when sending to iso-88591 and utf-8 database
Good evening friends, I have a problem where I can’t send data correctly to the database, when this data goes with special characters, name like D'vila always give errors. Has anyone ever had this…
-
0
votes0
answers45
viewsDatabase image does not load
Good morning, I’m trying to display an image previously recorded in a database in the form gridview, but this is returning an error and I can’t figure out what is wrong following the aspx snippet…
-
0
votes1
answer794
viewsSQL Server Row Number Counter
how do I perform a counter on the sql server from a certain number. Example below. Current result Ticket Ação 42977 1 42977 2 Expected result 42977 3 42977 4 42977 5 ---Below the query--- The first…
-
0
votes2
answers95
viewsQuery including multiple tables
I have a people table that has people from funcionarios, pais and maes, I’ve managed to relate everyone. Just look at the way it returns. I need the maes stay in the first line, just like the pais.…
-
0
votes1
answer33
viewsSelect help in two columns
I have the following select command: SELECT pa_coduni, pa_proc_id, sum(case when substr(pa_cmp, 1, 4) = 2017 then pa_qtdapr else 0 end) a2017, sum(case when substr(pa_cmp, 1, 4) = 2018 then…
-
0
votes1
answer488
viewsHow to change the order of the parameters in Oracle SQL Developer
I have a question regarding the order of the parameters within SQL developer. Query for example: select * from conta_paciente where cd_convenio = :cd_conv and dt_conta between :dti and :dt In older…
-
0
votes1
answer483
viewsSorting 2 Columns at the same time SQL Server
I have the following table structure. Ticket | Data | ID The data field is datetime, ticket, id and generator are int. What I need is for ticket and date fields to be sorted at the same time.…
-
0
votes1
answer48
viewsRecover the highest value in a column according to the repetition of the second
Good night to you all! I have a system in my company that records an entire value in a table every moment of the day. It also records the date and time in Datetime format; The table in the bank is…
-
0
votes1
answer327
viewsUpdate json field with select in the same Postgresql table
I have a table where I have to take data from a record and update it in a column from another record of the same table. These fields are like json. I was able to get the data to be entered but I’m…
-
0
votes4
answers288
viewsWhat’s this Join’s syntax error?
When do I use this join, appears that there is a "missing operator" syntax error, someone can tell me where it is and why this error occurs? SELECT tbEquipamento_Movimentacao.NUMERO_ATIVO_FK,…
-
0
votes1
answer625
viewsError converting varchar data type to float
I have a stored precedent to change a field of tables of varied name: CREATE PROCEDURE usp_alterarCrachaCadAce --PARÂMETROS @NomeTabela VARCHAR(20), @CrachaDestino FLOAT, @CrachaOrigem FLOAT AS…
-
0
votes1
answer505
viewsCheck if date is valid in Mysql database
Good afternoon programmers, I have a problem in the trial where I need to print all the dates of the month, I created a loop until the day 31, but there is month that is less days that gives error,…
-
0
votes2
answers553
viewsCopy data from one database to another?
Good afternoon, I am beginner in sql server and I came across a situation that raised this doubt. I wonder if it is possible to copy a table from one database to another, in the situation where both…
-
0
votes1
answer808
viewsHow to clean the data stored in memory, in cache or then reset an application (App) in android studio?
I am developing an application in android studio and need to solve this problem. I am using an internal database in Sqlopenhelper to store the products chosen by the user and show in a shopping…
-
0
votes1
answer59
viewsHow to return empty value in column?
Basically the logic should be the following. Return the Acs (aircraft) that has the component RCF6709 installed (case 1) or not installed (case 0). See: Retrieve active aircraft on AC_Master;…
-
0
votes0
answers96
viewsWin32exception: The network path was not found
I am getting the following error in my application that is hosted on aws Sqlexception: A network-Related or instance-specific error occurred while establishing a Connection to SQL Server. The server…
-
0
votes2
answers143
viewsStored Procedure Doesn’t Deliver Results You Should
-I am very new in SQL, Spring & Java, I am trying to set the results of a list that returns in a Query I created -this query returns a list with the referenced object -the parameters are all…
-
0
votes1
answer54
viewsSQL grouping product balance by company
What I need to do is I need to put together a report that will return the stock of products by individual companies. select must return the following:…
-
0
votes1
answer196
viewsError when adding foreign key to table
I get the error message: SQL Error [42703]: ERROR: column "tela_inicial_id" referenced in Foreign key Constraint does not exist ERROR: column "tela_initial_id" referenced in Foreign key Constraint…
-
0
votes1
answer77
viewsGet free hour ranges with SQL only
I am creating an agenda and need to perform a consultation of the interval between scheduled times. Example: Tabela: HORARIO_ATENDIMENTO INICIO: 08:00 FIM: 18:00 Tabela: Agenda ID: 1 HORA_INICIAL:…
-
0
votes0
answers33
viewsSQL Server Grouping Conditionally
I have the following problem. I have a relationship between 2 tables (1)Tb_log_relac_nfs and (2)Tb_fat_notafiscal_item. Table 2 is where I write both input and output notes. 1 is one that stores the…
-
0
votes2
answers54
viewsCodeigniter, update value with "CURRENT_TIMESTAMP"
Good, I want to update a table where in one of the variables I want to insert the value "CURRENT_TIMESTAMP". In a normal situation just send the value as a string and sql would interpret it and…
-
0
votes1
answer189
viewsQuery in SQL/Firebird grouping a sum by nature
I’m trying to make a Query in the product table to return to me the following information below: I’m trying to do it in a grouped way by totaling the values. There is a spine by name nature, that…
-
0
votes1
answer1012
viewsInvalid identifier during select SQL - Oracle
I am trying to seek information according to the business rule, which in case is ID and CPF of the Client of a certain City and this client in question can not have Debito active, but the ways I am…
-
0
votes0
answers27
viewsHow do I use a previous condition on Oracle?
I’m having a hard time using two columns as a condition in Where. I don’t know if I can explain it properly, but: WHERE P.PROFILE_STATUS = '1' AND P.JOBTITLE NOT IN (' -…
-
0
votes2
answers265
viewsORDER BY Mysql - Reporting organisation
I have a chat and would like to display the contacts according to the date of the last message, I thought of many ways to do this but it is not working in any way. How could I bring this data…
-
0
votes1
answer41
viewsHow to create a precedent that accesses a substring and calculates using the substring as parameter?
I need to create a precedent that according to the substring of a title, calculate the average price of books with the substring passed as parameter, and the average price needs to be an output…
-
0
votes1
answer28
viewsModal view with mysql database list
Hello, I have a database that is being displayed in a list on my site but I want to put a button to open a modal and display the information of each db line but whenever I open the modal it only…