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
votes3
answers106
viewsFilter per parameter or all
I make an appointment at the bank. I would like to filter the column ID_LEAD by the filter value "if there is" int?(filter.code) or filter all over the world. follows the example of how this in the…
-
1
votes1
answer355
viewsDoubt : Search with Dropdownlist mvc 4 Razor Asp.net C# sql Server
I’m having difficulty in popular dropdown with sql server, because it comes repeated sql item ... ex: when I select cities it comes with repeated cities and so on, and I can’t direct to search page.…
-
1
votes1
answer394
viewsIgnore group date/time field by
I have the following query: Select msi.segment1 codigo, msi.description descricao, pcn1.quantidade Qtde_Romaneio, nvl(SUM(pcn2.quantidade),0) Qtde_Coleta, (nvl(sum(pcn2.quantidade),0) -…
-
1
votes4
answers11284
viewsHow to create temporary mirror table in another
It is possible to create a mirror temporary table in another? Example: Let’s say I have in my bank a table with 60 fields. I would like to create a temp with the name #table with the same table…
-
1
votes2
answers718
viewsSELECT that brings products active in one company and that are not active in all others
I have a table that shows products that are Active (A) or Inactive (I) in 16 branches. IE, has 16 lines for each product. I want to select all products that are Active (A) in Enterprise 16 and at…
-
1
votes2
answers7167
viewsError trying to delete with INNER JOIN in MYSQL
DELETE FROM `tb_users` INNER JOIN `tb_marker` ON tb_users.id_users` = `tb_marker.id_users` WHERE `tb_users.id_users` = 12 Follow below the error: You have an error in your SQL syntax; check the…
-
1
votes1
answer603
viewsProblem when entering data into mysql database by java
My java code is working, but when adding data to an SQL table, the fields are being populated as NULL, even though added values. Part of the code into which the insertion occurs: public void…
-
1
votes1
answer41
viewsHow to realize the sum of values I multiplied?
I performed an operation that multiplies the amount of values by the unit value of each one, obtaining the total value per product. How could I add up the total values of all products? I tried with…
sqlasked 7 years, 7 months ago Brenno Rovea 23 -
1
votes2
answers515
viewsAbout Date in Mysql
I’m doing a program for a college job, with a database connection. On a table, I have a column NASCIMENTO of the kind DATE. On the show I have a MaskedTextBox to enter the date of birth, but I put…
-
1
votes0
answers124
viewsHow to know the index number in a multidimensional array?
Information: Rooms: 25; Teachers: 4; Q02, Q03, Q04: A student in a class classified the teacher from 0 to 10. From these numbers, a media was generated. There is a select with the list of teachers,…
-
1
votes2
answers950
viewsIf an int variable does not receive anything from select it is zero or not
Let’s say I have this block: declare @teste int declare teste_cur cursor for select campo1 from tabela ..... while @@fetch_status = 0 begin set @teste = 0 select @teste = campo1 from tabela where…
-
1
votes1
answer211
viewsSelect with cast(Numeric as decimal) works, but view creation does not
Good morning to all! I currently work with postgresql and am doing a database migration, and need to create a view of my old database tables. Well, I need the numerical columns to be rounded 15.3…
-
1
votes1
answer1014
viewsResultset first does not work
I am creating a Java application in Eclipse. I’m having trouble making the First, Previous, Next and Last buttons work. I’m stuck on the button First, because I believe the difference is just the…
-
1
votes1
answer49
viewsRemove first character by Index
Good afternoon. I have a varchar with some numbers set @ID_CUSTOMERNUMBER = '01234567' I would remove the zero only if it is the first number of my variable, example: '0123456789' removing the zero…
-
1
votes2
answers4867
views -
1
votes1
answer1567
viewsInsert data into Mysql database received from a Json
I have the following problem, I have an app and I send some data in Json format, to the server, until ai blz, enough good in this format:…
-
1
votes1
answer45
viewsConversion of a Date to Character sub-query in Oracle
i have a sub-query returning dates this way: SELECT DISTINCT DT_EMISSAO_NF FROM DANFE ORDER BY DT_EMISSAO_NF DESC And, starting from this query, I need all dates returned to be converted to…
-
1
votes1
answer61
viewsIreport report showing up without data
I am making a report with Ireport and passing a parameter with date range my sql in the report SELECT * FROM venda WHERE data between (venda.data = $P{dataInicial}) AND (venda.data = $P{dataFinal})…
-
1
votes1
answer5358
viewsHow to select a date in the dd/mm/yyyy format in mysql?
Good morning/late/evening I need to select a field TYPE DATE in mysql, the data is in the format yyyy-mm-dd, I need you to come back dd/mm/yyyy. Is there any way to do this in select? I’ve seen…
-
1
votes1
answer528
viewsHow to make an SQL (Mysql) query with medium and multiple INNER tables?
I have an instruction SQL with 5 tables. Note that I make even a calculation of radius. I need to add a new table of evaluations with: cod_evaluation int(11) cod_client cod_supplier general decimal…
-
1
votes2
answers2102
viewsCase no order by
I am trying to make an order by as the result of sql: sql.... order by cod_rua, case cod_lado when 'M' then cod_lado desc else cod_lado ASC end, cod_altura Only you’re making a mistake on the way…
-
1
votes1
answer78
viewsSelect the most repeated data in a column and display them
Good evening, I’m on a project where I should make a site that gives users to recommend movies, and then show the most recommended ones. I already made the system to recommend, now I need to make…
-
1
votes1
answer1039
viewsSQL query with SUM, displaying the return in rows
So class I have a question that is consuming my insides. Someone would be happy to tell me how to return a total of records from a query, via SUM (SQL Server) function, displaying the total number…
-
1
votes4
answers1444
viewsExcel transpose row to column and preserves columns and replicate them in row
Hello, Next, I have a CSV as follows: A;B;C;D;1;2;3;4;5 E;F;G;H;6;7;8;9;10 The columns of letters have a regular structure, whereas the columns of numbers do not but you could blow them up and put…
-
1
votes0
answers136
viewsSave multiple photos in SQL Database in same ID
I’m having trouble saving multiple photos in a single id this is the Cs of the page that makes the register protected void btnSalvarImovel_Click(object sender, EventArgs e) { try { var cmd = new…
-
1
votes3
answers94
viewsSelect with Count and add
I need to perform a select, which bring the total number of students enrolled per class and company, only when it is company ('X' e 'Y') add up the total amount of them, ('D' e 'F') also add up the…
-
1
votes3
answers2752
viewsComparison of Strings in sqlServer
Good morning. I have two strings defined : '2.9.15' and '2.9.16'; I need to compare them and tell you which one is the biggest. I don’t know how to do.
-
1
votes1
answer8718
viewsReturn only the last record inserted in the Mysql database
Hello guys I’m with a project but I have to make a query and return the "last line" or last record inserted in the database.
-
1
votes1
answer1275
viewsAllow null value in relationship field
I have a database MySQL with tables t1 and t2. One of the columns in the table t1 has a foreign key to t2. You need to allow the foreign key column to accept values null. Important data already…
-
1
votes1
answer2224
viewsQuery the database through a text box
Hello, right now I’m in a part of a project where I have to do a database search through a text box. For example, he searched for "José" and returned all the data contained in the database with the…
-
1
votes2
answers151
viewsCount function - Mysql
I have the following tables: times - time_id INT - time_nome VARCHAR rodadas - rod_id INT - rod_rodada INT - rod_pontos DECIMAL (10,2) - rod_fk_time INT I need to add the score and group by team.…
-
1
votes3
answers707
views -
1
votes1
answer263
viewsI want to use Web sql but I’m not able to create table or insert information in it
let db = openDatabase('produto_teste','1.0','banco de dados para cadastro do produto',2*1024*1024); db.transaction(function(tx){ tx.executeSql('CREATE TABLE IF NOT referencia(\ id INTEGER NOT NULL…
-
1
votes1
answer51
viewsDoubt about data type database
See this table of INT data types in SQL SERVER: tinyint | 0 a 255 | 1 byte smallint |-2^15 (-32.768) a 2^15-1 (32.767) | 2 bytes int |-2^31 (-2.147.483.648) a 2^31-1 (2.147.483.647) | 4 bytes About…
-
1
votes1
answer428
viewsAdd values and subtract values from another condition
Good afternoon I have a table named TITLE In it I have columns with name CODOPERACAO, VLROPERACAO, DTAOPERACAO I have 2 different records of CODOPERACAO that are: 16 = Inclusion of title 28 =…
-
1
votes1
answer424
viewsCPF Validation - Integration Services
I am importing a base with Cpfs for my DW but need to do CPF validation inside SSIS. Does anyone have any idea how I can do that? Thank you! Edit: I got it done the way I wanted it. I used the…
-
1
votes2
answers66
viewsSQL filter (Result that should not appear)
is the following I am creating an online schedule and need to list the and show the times that are not scheduled, to show the schedules free. And for that I created the schedule_schedules table…
-
1
votes1
answer918
viewsMysql query - Take the next value greater than 0
Example, I need the query to return me these circulated values. The previous result was 0 (zero). The current one is not. I need to take the current one. And list…
-
1
votes0
answers72
viewsDuplicate image error on save!
My function that saves the images in the folder works properly, but when I open the photos folder the images appear duplicated however with different names Follow the save function: protected void…
-
1
votes2
answers785
viewsHow to show the result of a query based on the result of another?
Consultation A: SELECT V.CHAPA AS CHAPA, F.NOME AS NOME, V.DATA AS DATA, DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) AS DIFF FROM V_BATIDASANTIGAS AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA…
-
1
votes1
answer33
viewsHow to maintain the Sql connection for a long time
My application makes the select on the table To server 1 and with the result of select is made a insert on the table B server 2 with the query data. The routine works for a certain time, then I have…
-
1
votes1
answer31
viewsCheck the difference between unlisted results and identify which day of the week is the date
I have the following appointment: SELECT V.CHAPA, F.NOME, V.DATA, MAX(V.SEQUENCIALBATIDA) AS BATIDA FROM ARELBATIDATRANSITOVIEW AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA WHERE V.CHAPA =…
-
1
votes1
answer642
viewsDifference of days between records and display only results > that 14
I have the following appointment: SELECT V.CHAPA, F.NOME, V.DATA, DATENAME(dw,V.DATA) AS DIA, MAX(V.SEQUENCIALBATIDA) AS BATIDA FROM ARELBATIDATRANSITOVIEW AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA…
-
1
votes1
answer104
viewsA creak within a range
I have a problem and I’m looking for the best way to solve it. I have values of Min and Max coming from a database: Ex: id Min Max 1 5 10 2 20 25 3 60 90 4 91 99 If you are going to insert a new Min…
sqlasked 7 years, 5 months ago Ricardo Caldas 11 -
1
votes1
answer94
viewsGroup continuous repeats with Mysql
I was wondering if there is any way to group repetitions using Mysql only. If you make a SELECT * from tabela WHERE id_usuario = 1 ORDER BY id ASC will return: id | id_usuario | Data | Texto 0 | 1 |…
-
1
votes1
answer1615
viewsCan I run a Python program automatically off my computer?
Good morning guys, I made a Python script that searches various websites for the occurrences of a few words and stores in SQL database. I would like to track the occurrence of these words over time,…
-
1
votes1
answer293
viewsHow do I search with a text variable containing apostrophes?
Problem When searching with texts containing apostrophes, no results are found. Execution DECLARE @cidade NVARCHAR(50) SELECT @cidade = cidade FROM tabela_A WHERE id = xv SELECT campo FROM tabela_B…
-
1
votes1
answer1777
viewsAccess SQL Server base via CMD
In Oracle I know you have how to access and execute queries through sqlplus in CMD. Can anyone tell if SQL SERVER also has a similar command?
-
1
votes1
answer55
viewsJPA in java web
I am with a JAVA WEB project and I am having problems with Hibernate. The error is as follows: Informações: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} Informações: HHH000412: Hibernate…
-
1
votes2
answers508
viewsHow do I do INNER JOIN in this case?
I’m a beginner in Postgresql and I need to make a INNER JOIN to relate data from two tables. It took me a long time to understand this FOREIGN KEY, but I made the right reference in the database.…