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
-
-1
votes1
answer34
viewsSpecific rows of a table
Hello! I have the table OPERATION where I have 3 columns: Codoper, Description, nauteness. I have to design the description and nature of all incoming operations. Then sort by the operation code.…
-
-1
votes1
answer380
viewsDatabase Modeling (Entity Relationship Model)
In the image below is the modeling of the following problem. I have users where these will belong to modules(Physical module, Portuguese module, chemical module) are 3 modules in total.One and only…
-
-1
votes1
answer399
viewsImport SSIS file with columns at different positions each day
I have the following situation: I make a Flat File (Simple File) import from a *.CSV file to a table in the database. Using SSIS in Visual Studio. However, each day the file I receive has the order…
-
-1
votes1
answer1246
viewsSql server convert String time to Decimal
Guys I’m having a question of how to convert a column string that brings the time like '08:00:00' to decimal, just like Excel does, when it changes the format to number for example: '08:00:00' =…
-
-1
votes1
answer1839
viewsSQL To Count If Greater Than 1
My problem is this: I have to make a condition if the SEQ_VENDA has more than 001 NUMERO, it bring the SELECT data. And if you only have 1 NUMBER for SEQ_VENDA do not bring in SQL…
-
-1
votes1
answer381
viewsHow to check null fields in sql?
The Trigger I have to do: A user can only classify an offer if he has purchased it (reservation with estado = pago). On the other hand one of the two attributes classification and comment has to be…
-
-1
votes1
answer3233
viewsTake only the value and format in 2 decimal places
Well, I have a python script that queries two different databases to verify values per day, one in SQLSERVER and the other in Postgres. I used an if to warn if the values were different and if it…
-
-1
votes1
answer61
viewsConsultation with pause?
well I am making a php dynamic menu where I would not use query within another, I am currently searching from the CATEGORY table the name of the category and within it I am searching in another PAGE…
-
-1
votes1
answer111
viewsMigration oracle to sql server
Can anyone indicate me a good data migration tool for the oracle database to the sql server database and vice versa? I need to take a lot of records from the oracle database and save it in the sql…
-
-1
votes1
answer110
viewsSelect only the first line of each user
I have a table where move balance (deposits and withdrawal), but in a field of the site need to bring only the balance of the first deposit. It would be something like that: select saldo from…
-
-1
votes1
answer172
viewsred/negative and green/positive
I have a table that, time the value is negative and, time is positive. I would like these values to be green or red. But, I couldn’t do it. Currently my select is being presented this way: (php,…
-
-1
votes1
answer251
viewsHow to import a . sql extension file into SQL Server 2014?
I received a file that it has the . sql extension, so every time I import something into sql server is from .bak. Is it possible to do this? If yes, how?
-
-1
votes2
answers345
viewsProblems with Laravel Query Builder
I have the following problem, when trying to implement a consultation with joins, in query Builder: My Query (pure SQL): SELECT COUNT(*) as total, orgao.sigla AS sigla_org_uni FROM protocolo INNER…
-
-1
votes1
answer36
viewsHelp with Update SQL
I need to learn how to update my chart. I have the "Person" table, this one has the "Description" column. At the time it was created a maxlenght of 100 characters was added, I need to change this so…
-
-1
votes1
answer511
viewsArray[] in database, how to create and manipulate?
I own a array of integers, a int[]. Is it possible to save it directly to the database without having to Serialize? For example: CREATE TABLE teste( numeros integer[] ); And then use SELECT numeros…
-
-1
votes1
answer295
viewsCheckbox
I’m having trouble creating a web page where I have select boxes dependent on it. For example, after selecting the first box the values of the second one vary according to the selected option. The…
-
-1
votes1
answer325
viewsOracle - Alias in Case
How can I put an alias in the column name in a CASE? CASE atu.cod_situacao_matricula "Alias" WHEN 2 THEN 'Matriculado' CASE atu.cod_situacao_matricula as Alias WHEN 2 THEN 'Matriculado' Both give…
-
-1
votes2
answers4491
viewsQuery Search Specific Word in a Field - SQL Server
Is there a function that I can only find the data of a field ? I’m only trying to get from Expiration until 2019, I have several lines with this validity information, and they don’t appear in the…
-
-1
votes1
answer32
viewsScan 4 selects and display message
Speak up, people, blz? I would like to know how to make the following logic in SQL: if( 1 = select * from tblA or 1 = select * from tblB or 1 = select * from tblC or 1 = select * from tblD or )…
-
-1
votes2
answers1108
viewsCommand to set a default value for a column in SQL Server
Hello, I want to know the command to set a value like default in SQL server. The table name is "Table" and the column name you want to change is "COLUNA2".
-
-1
votes1
answer130
viewsSLA calculation in Postgresql
I want to calculate the time between the registration date so far (current_timestamp). Ex: If the record was 2019-03-01 09:11:17 and now it’s 2019-03-01 09:46:17 then it should return me 00:35:00…
-
-1
votes1
answer85
viewsSubconsulta SQL
I’m doing the consultation below: select idtce from tab_tce where idempresa = 2493 and YEAR(dt_inicial) = 2018 and idtce not in( select TCE_ID from SEC_VAGA_ESTUDANTE ) But returns this error: Msg…
-
-1
votes1
answer36
viewsTable with default value not loaded
I created a table GrupoDesconto, with three fields: Id, Descricao and MargemDesc. On the table Revenda, created a foreign key (Foreign key) GrupoDescontoId who receives the id of GrupoDesconto and…
-
-1
votes1
answer64
viewsSQL search specifies
Ola wanted to do a database search with and that only brings the answer if conditions are reached used code. $sql2 ="SELECT * FROM `link` WHERE 1 LIKE…
-
-1
votes2
answers117
viewsHow to get lower value without aggregation function - SQL
Assuming a Student table that has as attributes(Id, Name, age). How I get the name of the underage student but without using aggregation function(MIN)?
-
-1
votes1
answer56
viewsRelationships of Tables and Databases
It’s a simple question, which is restriction of integrity of relationships. Please help me, I have a TCC in a week and I haven’t finished this thing yet :'(
-
-1
votes1
answer26
viewsHelp, how do I save the image path in my bank?
I wanted to create an imagem_prod field and do the Insert, as I do? images are in this folder C:/xampp/htdocs/(project/img/products)? CREATE TABLE produtos ( id int NOT NULL auto_increment primary…
sqlasked 5 years, 6 months ago user456711 11 -
-1
votes1
answer25
viewsHelp mount select
Product Table TB_PRODUTO: CODIGO PRODUTO ST_PRODUTO DT_ENTRADA 1100 NOTEBOOK 0 20/05/2019 1200 NOTEBOOK 1 21/05/2019 1300 NOTEBOOK 2 22/05/2019 1400 NOTEBOOK 0 23/05/2019 1500 NOTEBOOK 2 24/05/2019…
sqlasked 5 years, 6 months ago Jessica Ribeiro 1 -
-1
votes2
answers260
viewsPython string prefix
I made a script to download an attachment from an email, this attachment is an XML file, and I want to save it in a database. But when I get the XML body, it comes with the prefix 'b' and therefore…
-
-1
votes3
answers705
viewsAvoid duplicate records in a particular Mysql column
I have an auction system where several users can bid, but I have a problem when bids occur at the same time, as they are entered in the database with the same value in the column bidding_price, ex:…
-
-1
votes1
answer346
viewsDelete records with multiple conditions
I need to delete duplicate entries in the column bidding_price with the following conditions: Table: bid_account Columns to be checked: id = PRIMARY KEY auction_id = ID of each product bidding_price…
-
-1
votes1
answer169
viewsHow to know the number of films by categories that have less than 50 films?
I have a movie chart with: -id_film, -movie name, -id_category; And another category with: id_category, category name; how do I select only the category and amount of films of those that have less…
-
-1
votes1
answer86
viewsSQL return relationship data on the same line
When carrying out the consultation SELECT [Product_Id] ,[ProductTag_Id] FROM [Product_ProductTag_Mapping] I have the result I need Saida to be:…
-
-1
votes1
answer36
viewsOrders greater than 30 days
good afternoon. I am putting together a report in which I need to report in a column, products that have not had movement for more than 30 days. The field I use is of DATETIME pattern. Every time…
-
-1
votes2
answers153
viewsRemove duplicity in two columns
I would like to know how to resolve the following situation I have a view where the item code is duplicated by the key of another column ex: data------cod_prod-----descricao-----…
-
-1
votes1
answer42
viewsinsert xml record plus date into a time table
I wanted to make this select but I can’t > DECLARE @XML XML > SET @XML = > '<rows> <row> <tracking> JU148345357BR</tracking> </row> <row>…
-
-1
votes1
answer73
viewsHow to select the highest value of the following query?
SELECT SUM(DISCIPLINA.VALOR) + MATRICULA.VALOR FROM ALUNO, MATRICULA, MATDISCIPLINA, DISCIPLINA, SEMESTRE WHERE ALUNO.CDALUNO = MATRICULA.CDALUNO AND MATRICULA.CDSEMESTRE =…
sqlasked 5 years, 2 months ago Hiago Pais 3 -
-1
votes1
answer40
viewsSQL performance when dividing results into categories
I have a bank with all the products of my store, I want to list the products by categories but I do not know what is the most efficient way to do this, because it is a big bank. It would be better…
-
-1
votes1
answer46
viewsJava Nullpointerexception error in construction
main java. package projeto; import java.sql.*; import javax.swing.JOptionPane; import java.sql.Connection; import java.sql.Statement; import java.sql.DriverManager; import java.sql.ResultSet; import…
-
-1
votes1
answer118
viewsRelationship between different file tables
In Access it is possible to link between tables that are in different databases (files), this resource is called in Access table binding. I mean, I can have a table called CLIENTE in an archive…
-
-1
votes1
answer67
viewsDisplay average wage by years of service
I have the FUNCIO table that has as columns matricula, name, anoServico, salary. I would like to display the average wage per yearService. How to do? Thank you!
-
-1
votes2
answers305
viewsHow to merge 4 tables into one and show text instead of INT - INNER JOIN
Hi, I know it’s kind of like this in the second print and with Inner Jay but I’m not getting it. I’m using Mysql Workbench and more when I finish this I want to go to C#. I have this doubt, I have…
-
-1
votes1
answer263
viewsSpring V10 Run SQL
I’m trying to migrate a code V9 to the V10 which basically inserts SQL records into a user table from external software. In V9 I do this easily using for example: strSQLAux = "INSERT INTO…
sqlasked 5 years ago Ricardo - Bragaconta 29 -
-1
votes2
answers471
viewsWhen I perform a SELECT it returns multiple duplicate records
When I perform a SELECT it returns multiple table posts records with same id; I tried to use DISTINCT not to return these records but it’s still returning duplicate records. SELECT DISTINCT * FROM…
-
-1
votes1
answer41
viewsHow to return an sql answer?
This is my first forum post, so I apologize if I make a mistake. The thing is, I need to register a book in the bank, but before that, I need to know if the author is already registered in the bank,…
-
-1
votes1
answer54
viewsUpdate json object in a varchar column
Guys I’m having a problem at Postgres, I have a column that’s in format varchar but as a need I have to put a saved JSON object in it {"value": "value", "value2": "value2"} It is possible to update…
-
-1
votes1
answer49
viewsWhat is the best way to search for many variables in the database?
I am developing a C# MVC application and am having problems presenting the records. I have a list of over 250 variables and the user chooses which one he wants to see on the chart. Inside the…
-
-1
votes1
answer125
viewsHello, I have a database - mysql and would like to decrease a value in an entire column
I’d like to use the command update to decrease an hour in the values you already have in the table of several values in the whole column. EX: Nome da Coluna Gostaria da coluna assim HORA HORA 13:45…
-
-1
votes1
answer55
viewsCopy content from one table to another
I have a table, a call "Cars" with the columns Carid | image another table called "Pictures" with the columns picID | Inname I would like to copy all photos from table "Cars" column "image" to table…
-
-1
votes1
answer160
viewsCompare duplicate records in the database with PHP and Mysql
I am trying to make a condition that prevents you from saving the same login name of another already registered user. $login_fail=("SELECT DISTINCT $login FROM login"); if(empty($nome)){ $errMSG =…