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
votes3
answers814
viewsSELECT WITH STRING FORMATTING
Using the Mysql Database, intending to perform the query in a given table whose one of its fields data has as type VARCHAR(8). Query SQL - Current SELECT `t_movimentacao`.`data` FROM t_movimentacao…
-
0
votes0
answers41
viewsHow to not duplicate my LISTAGG
Follows my sql to low oracle use SELECT DISTINCT pf.nome AS servidor, m.matricula AS matricula, ca.descricao AS funcao, TO_CHAR(c.dataadmissao, 'dd/mm/yyyy') AS admissao, LISTAGG(ev.descricao, ',')…
-
0
votes1
answer257
viewsHow to take all values of a select and run in a Procedure?
How to take all the values of a select and play in a precedent to give an Insert without running one value at a time? I have the following sql code: --drop table #tabelaEntSaida; --drop table…
-
0
votes1
answer131
viewsHow to make a bit flags selection filter?
I am a database novice and am participating in an Oracle-SQL project where I need to create a flags selection filter in a column that stores flags as active or not from the position of each binary…
-
0
votes0
answers56
views(Java) Error connecting to SQL Server Local
I am trying to get my project to connect with SQL Server Local, but it is showing the following error: run: Algo deu errado! java.lang.ClassNotFoundException: C:\Program…
-
0
votes1
answer45
viewsQuery SQL returns data that was not to be returned
Well, I’m putting together a ticket sales system for football matches as a project of my course I’m working with the Laravel + Eloquent ORM, but I’m having an inconsistency. My code is: $matches =…
-
0
votes0
answers46
viewsHow can I create multiple $_SESSION in one function?
To be clear, I am developing a simple PHP and SQL application, which has been breaking my head in the last few days... <?php session_start(); include 'header.php'; include 'db.php'; $pesquisa =…
-
0
votes1
answer29
viewsConversion error
I’m trying to update a schedule through Jtable. But when I try to update it gives an error java.sql.Sqldataexception: data Exception: invalid Character value for cast private class BtEditarListener…
-
0
votes0
answers164
viewsCreate a column that shows SQL percentage
I have a query that searches 2 values and when divided should return the percentage, but this with integer number. I believe I’m wrong here : (COUNT(distinct neighborhood) / COUNT(distinct…
-
0
votes1
answer110
viewsDifficulty creating a mysql query
I have this table: Typotarefa: Id, Descricao 17, Depilação Buço 18, Depilação Pernas 19, Depilação Orelhas 20, Depilação Barba 21, Cortar Unhas Pés 22, Cortar Unhas Mãos 28, Esvaziar Saco Urina 29,…
-
0
votes1
answer28
viewsGet records that have equal values
I want to get the contact table records that have the same email. Only the email is a field of the email table because this way the contact can have several emails (One To Many). // Tabela contato…
-
0
votes1
answer69
viewsProblems in select using Having MAX non-boolean expression
I need to make a select to pick up all the patients who have been consulted over a period of time in a specific sector, and see when their last comeback was, and if they are more than a year old not…
-
0
votes1
answer106
views(JAVA) Error returning record amount using SQL COUNT
I’m trying to return the amount of record of a table, in this table I currently have 6 records but my Query returns only one, as if there were only one record. I need you to return the full amount,…
-
0
votes1
answer22
viewsError of procedure call
I’m having a problem calling one procedure within a function in the SQL. When I call the function CHECK_LOGIN for SGBD, does the operation without any problem, but I need to do this operation by a…
-
0
votes3
answers155
viewsHow do I play an input value without submitting a form or button
Hi, I wanted to get the input value "codigo_cat" and play in the variable $id_categoria that is at the bottom of the code PHP, to be able to run select using this variable as parameter. By method…
-
0
votes1
answer70
viewsColumn not found when performing SUM
I’m developing the system for a school. I need to create the vacation part. For this I need to add the number of days already launched so that per year are not launched more than 30 days per…
-
0
votes1
answer61
viewsInsert direct tuple with SQL in a Django view
I’m using Django in two projects (let’s call Project1 and Project2) that relate and share the same database, but because they are different projects, they do not share the same apps. Now I need to…
-
0
votes0
answers88
viewsIs it possible to force a value when select has no search result?
Good guys, I have a situation where I need to show the balance of billing per client, as I could in no way use a select that combines the result of two other select, I decided to use the separate…
-
0
votes0
answers1421
views#2054 Unable to login to Mysql server - Phpmyadmin - APACHE ( PASSWORD ERROR)
I was doing the settings, at the time of installing mysql I ended up putting a password but ended up missing believe. Now when logging into Myphpadmin - it gives this error. I’m Using Apache>…
-
0
votes1
answer917
viewsMerge two queries in SQL Server
Hello, I have two queries of the same table, but I’m not able to join them parallel, I tried to use the UNION, but it didn’t work, is there any way to do it? Or else create a column with the…
-
0
votes1
answer48
viewsAdd values with different codes
good evening, I have the script below: SELECT Month([doacao_total].[doacao_sdt_data]) AS MES, Year([doacao_total].[doacao_sdt_data]) AS Ano, Sum(doacao_total.doacao_mon_valor) AS [Valor_doacao],…
-
0
votes0
answers46
viewsHow to adjust this query?
I need to adjust this query to do the search (like) in another column and another table. Behold: $query2 = "select distinct(lances.codigo), datacompra, horacompra, cupom from lances, ".$tabelaCad."…
-
0
votes1
answer372
viewsHow to run a WSDL Webservice from a SQL Server Stored Procedure
Does anyone know how to create an SQL Server database to run a stream Webservice ? The idea is to create a process from the execution of Procedure I read about the Ole Automation Stored Procedures…
sqlasked 5 years, 3 months ago Fernando Lima 1 -
0
votes1
answer56
viewsHow to make a "Case When" when the condition is called a Package with the function and Passed the Parameters?
I am trying to make a modification in the Query without destroying a logic already made. Original Query: IF Pcoluman = 'aceito' THEN if (v_respon_alg = 'Y') OR (v_respon_las = 'Y') OR (v_respon_nye…
-
0
votes0
answers33
viewsHow to connect to database to login - PHP
FORM - <form action="" method="POST"> <input type="text" name="username" id="username" placeholder="Username"><br><br> <input type="password" name="password" id="password"…
-
0
votes0
answers30
viewsHow to return time in Mysql even without registration at that time
I need to group data in a 15-minute interval, giving me the total number of vehicles in a given date range. What I got so far was this query: SELECT Date_format(data_hora, "%y-%m-%d") AS dataFormat,…
-
0
votes0
answers230
viewsUse two fields with different settings on Oracle
I’m having a hard time: I’m trying to use a field that was created as number with a field created as NUMBER NOT NULL ENABLE. The ID_ACESSO field was created like this: "ID_ACESSO" NUMBER NOT NULL…
-
0
votes0
answers43
viewsHow to list the number of open records and which were served in the same sql?
I need to get the number of open calls and the number of open calls that have been answered, all grouped by month. I’m trying like this: select T_aberto.mes, T_aberto.qtd_aberto,…
-
0
votes1
answer32
viewsSelect Sql Query Manipulation (Multiple Combo option in Zend)
Good morning, I have a "Select" that lists as an option everything in the table "areas", followed by the word "ALL", Below each "area" option are listed those sub-areas that link to the area. When…
-
0
votes1
answer205
viewsQuery sql to search for and a string equal to but larger than the one stored in the table
I have a table that stores screen urls from my system, I wanted to perform a query that returns me a url that comes parameterized as follows /avaliacoes-cozinha-segura/avalia-cozinha/2 to that url…
-
0
votes0
answers55
viewsEfficient SQL Server Index
Ladies and gentlemen. (as), I need help to build an efficient index for an SQL table. I have a table that is causing me a certain headache, because it is consulted with a certain frequency, besides…
-
0
votes1
answer981
viewsGrouping data by hour intervals in SQL Server
I currently have the following query in the SQL Server database: SELECT TOP 5 CAST(CAST(CAST(CAST(E3TimeStamp as float)*24 as bigint) as float)/24 as datetime) as hora,…
-
0
votes1
answer51
viewsHow to select two Columns with Different values when the ID Matches
Let’s Say I have 1 table (1) with the users info. A table 2 with users plans. I need to select each users plan and show on the same line in case he’s got more than 1 plan. TABLE 1: +------+------+…
-
0
votes1
answer207
viewsHow to Update in Two Table?
I’m looking to make a update in two tables, postgres. I’ve seen some posts using other banks and I believe I’m doing the same, maybe some particularity of the bank or is missing something. Update in…
-
0
votes1
answer152
viewsSQL query to add Rows and display in two Columns in MYSQL
I would like to display the sum of several rows, only in two columns. All information is in the same table. Only the criteria change. Ex: I want the SUM of a column with WHERE and I want the SUM of…
-
0
votes1
answer49
viewsPurge invalid data before creating a Foreign Key (FK)
I’m working with a database bequest where there are 3 tables: Tabela A, Tabela B and Tabela C which stores the relationship between Tables A and B, however when the bank was created the Foreign Keys…
-
0
votes2
answers79
viewsPivot with Temporary Table
Hello. I am building a query where I need to use pivot to analyze the results, but it does not return the necessary data. Original table: select * from tbCampoAdicionalTicket where TCK_SEQUENCIAL =…
-
0
votes0
answers40
viewsEdit table with corresponding value <select>
I have a form to edit the table data, it is working normally. But when loading the page is searching for the last name of the table. I would like to know a way to load the page, come already…
-
0
votes1
answer66
viewsField cumulativity calculated using Sqlserver
I have the following table: Therefore, I need to accumulate the value of the expression using SQL Server and the only way I could do it was using cursor; someone has another idea? USE TEMPDB GO IF…
-
0
votes0
answers42
viewsRelationships using OPENDATASOURCE function
I need to list a table from one server and a view from another. I researched the function OPENDATASOURCE and later implemented it in the query. When executing, the program returns this message to me…
-
0
votes3
answers51
viewsThe image does not appear on the page
<?php session_start(); include "conexao.php"; $sql = "SELECT * FROM noticia"; $noticia = $conn->query($sql); $conn->close(); ?> <?php include "include/header-adm.php" ?> <!--…
-
0
votes1
answer46
views -
0
votes2
answers893
viewsValidate data in sql server
I get a date, and I need to know if it’s valid, if it’s not, I need to shorten her day until it’s valid. set @data = (select…
-
0
votes0
answers271
viewsUsing Count(*) as a table filter
Good morning, I’m breaking my head with the following code: select ac.cd_agenda as "Código Agenda", m.nm_pessoa_fisica as "Médico", esp.ds_especialidade as "Especialidade", a.ds_complemento as…
-
0
votes2
answers314
viewsReturn last entry of each product
help me. I’m in a situation where I want to bring only the last note entry of each product to create a report. I created a select, but there are products repeating where they shouldn’t. See select:…
-
0
votes1
answer138
viewsTrigger which arrow default value for a field
follows the statement: If the employee department code is not Insert or if it does not exist in the table , assign to it the value standard 20; And I made the following code: create or replace…
-
0
votes2
answers519
viewsSQL Query average time DO NOT take into account Weekends and holidays
I need to average the time it takes since creation (a. Date of creation) until completion (s. Data_status_finalized) field. Not able to count weekends and holidays. The following query is working,…
-
0
votes0
answers103
viewsPython connection with SQL Anywhere 16 fails
Hello! I’m trying to connect Python with a Sybase database but all the ways I try, ends up giving this error. Traceback (Most recent call last): File "C: Users Yuri.Mendonca Appdata Local Programs…
-
0
votes0
answers264
viewsRuntime error '424' when running SQL
I’m trying to send data from excel to access through a macro. I edited on top of a ready and it seemed to me that I was doing the same thing, but it gives "Error at runtime 424 - the object is…
-
0
votes3
answers279
viewsuse of cursor to update item to item stock
I have a bank where the stock(onhand) must be changed each time an order(docentry) is made, whether it is a confirmed order or not, for that I need to download the order quantity(Qty) with a simple…