Most voted "select" questions
USE THIS TAG ONLY WHEN REFERRING TO DATABASE. SELECT is an SQL statement that returns zero or more rows, from one or more base tables, temporary tables, or views in a database. DO NOT USE to refer to the HTML "select" element, in which case use [html-select].
Learn more…807 questions
Sort by count of
-
0
votes1
answer49
viewsMaximum value per category
I am doing a job in which I would like to show the maximum balance of each account type with subselect within the SELECT. Something more or less like this: CodConta ---------------------tipo…
-
0
votes1
answer107
viewsSelect more than one item with the select tag
I’m having a problem, the html tag allows the user to select only one option from the list, however I need to select more than one select item, how to do this using only JS? I need to select which…
-
0
votes1
answer32
viewsGroup By com sql server
I am trying to group the data of my select , according to the field C9_CARGA , however when I run this select it returns me without being grouped , I believe I am doing something wrong . How are you…
-
0
votes1
answer105
viewsSQL - UPDATE with value from SELECT
Dear, I have two tables (A and B), in which B has a foreign key of A. Example: A(id, campo1, campo2) B(id, idA, campo3, campo4) I need to count the amount of B.idA and thereby define a true or false…
-
0
votes1
answer158
viewsSwap subselect with Oin
good morning! I’m sorry if explanation is not totally clear, it’s because I’m starting in SQL. How do I replace subselect with some type of Join? Because subselect takes longer to load. Examples:…
-
0
votes1
answer41
viewsLogica in SELECT, display either record
I need to use the rule that is in the if within my select. Main rule is if you have the purchase and the purchase has the approved status I must bring the field with the url of the final product if…
-
0
votes5
answers97
viewsDoubt with Select using ORDER BY
I’m trying to make a SELECT so that it displays from the second table only the most recent record. I tried to do it using GROUP BY and ORDER BY, but with the GROUP BY mine SELECT does not work, only…
-
0
votes0
answers20
viewsMultiple select comparing two database lists
I need to make a multiple selector in HTML, and the list of items will be loaded from a Mysql table using PHP, however, I want the values that are already in another table to be filled…
-
0
votes1
answer38
viewsHow to select in MYSQL, bringing together results
I need to make a query that returns the amount similar to the below: TIPO 1 unidade 1 unidade 2 unidade n TIPO 2 unidade 1 unidade 2 unidade n The tables are like this: tabela_tipo id|tipo 1 |TIPO 1…
-
0
votes1
answer37
viewsTotalize products through two tables - Mysql
I wish the result of SELECT to return: Product name | Credit | Debit | Balance Badge 076 |10 | 5 | 5 Badge 064 | 20 | 10 | 10 Table: products [product.id / product.name] Table: badges [badges.id /…
-
0
votes1
answer401
viewsHow to calculate value + sum(value) within a select
Hello I plan to make a select in that direction: select NUM_PEDIDO, VALOR, ((VALOR/ sum(VALOR)) * 100) as PORC from PEDIDO Obviously this will return me this error: (... is invalid in the select…
-
0
votes1
answer39
viewsOnchange does not fire
Oie! So I’m unable to add an event onchange on my select tag. HTML <select class="onchange"> <option>Selecione um assunto:</option> <option value="pratica">Receita de pães…
-
0
votes1
answer61
viewsOracle SQL Query with Group By starting and ending on different days
I need to sum up grouped numerical records per day within a month, I have the timestamp of all records, but I can’t make a group by because my day starts with the 00:15 record and ends with the…
-
0
votes2
answers157
viewsMysql message: #1241 - Operand should contain 1 column(s) - Copy data from different tables and databases
I need to copy database A data from table A (14columns) to Database B table A (15columns) I need to check accountid if there is no database B table A must copy the data, if there is no. I tried the…
-
0
votes2
answers62
viewsUnion of select’s to return only 1 query
We need to perform the following queries in only 1 select: 1st SELECT SELECT SUM(FAPEDIDO.TOTAL_PEDIDO) AS TOTAL_CAR, FAPEDIDO.CD_REPRESENTANT COD_REPRESENTANTE, GEEMPRES.NOME_COMPLETO REPRESENTANTE…
-
0
votes1
answer23
viewsI want to hide the small
I have a select that has one with descriptive text. I need it to be hidden when you click the select and open the list of options, but it will be visible again when you click the select, or one of…
-
0
votes2
answers33
viewsSelect in 3 tables returning multiple Oids
Script only works by returning a single codpro (4609), needed it to return several SELECT a.filial, a.codpro, b.descricaolonga , a.quant, a.estminimo, c.filial AS 'filial ped', c.quant AS…
-
0
votes2
answers71
viewsHow to do WHERE with an incomplete name to find the record that in the bank is with the full name?
Hello, I need to get the system to email the registered person on a form as the engineer in charge. Then I need to make an SQL that looks for the email from the name. So far ok. If the person type…
-
0
votes2
answers53
viewsUnion of two selects presenting online
Below is a query performed for ORACLE database: SELECT ITOS.CD_NUMERO_OS, ITOS.DESCRICAO_RECLA AS "DEFEITO APRESENTADO" FROM GMITEMOS ITOS INNER JOIN GMOSERVI OS ON OS.CD_NUMERO_OS =…
-
0
votes1
answer32
viewsFind the year in which total customers (sum) was higher
I’m using sqlite, and I have a table like: year | clients ---- | ------- 2000 | 1 2000 | 2 1999 | 3 1999 | 5 2000 | 4 1999 | 6 This is just one example. I want to find the year when the total of…
-
0
votes1
answer159
viewsoptions in html input
in html there is a property called SELECT and also the INPUT and I would like to make a INPUT with options equal to SELECT but how can I do that? the code I used: <!DOCTYPE html> <html…
-
0
votes1
answer49
views -
0
votes2
answers85
viewsSelect to create balance based on previous month’s value
I have the following situation. I have a Mysql database where one of the columns (liquido_dia) brings the daily value generated (positive or negative), I’m already mounting a demonstrative per month…
-
0
votes0
answers204
viewsORA-00933 SQL command not closed properly
Hello, good afternoon I am trying to run the following select on TOAD, but the error is occurring: ORA-00933 SQL command not closed properly SELECT ROWID, ECM_WF_PROC.IDWF_PROC,…
-
0
votes2
answers54
viewsQuery duplicate numeric field in sql server
Good morning! I have a table of notes and in the month of December there was a duplicity of several notes. These duplicated notes have different numbers, however, the total value of the note is…
-
0
votes1
answer64
viewsCrossing a primary key with 2 foreign keys from the same table?
I was studying some SQL and came across the following problem: I have 2 tables one called Order and another Locations, follow the fields below: ORDER id | data_creation | id_origin | id_destination…
-
0
votes1
answer20
viewsTaking data from a select to trigger an IF before sending the data (POST)
I am improving my original project, where the Giovane solved the problem I had, but now I’m in a situation where, depending on the select, I’ll have different options and actions. In my current use,…
-
0
votes1
answer17
viewsHow to add the WHERE condition in the SELECT table with server-side Processing?
I wanted to add a small SELECT condition to my table, but I am using the Datatables server-side Processing to list the records on the server side. I tried to adapt the standard Datatables code to…
-
0
votes3
answers27
viewsINNER JOIN between two SELECT
I can do the INNER JOIN between two SELECT following the structure below? For the idea is to add a few more SELECT /* Select 1 */ SELECT AVG (UR1_Demanda) as UR1_DemandaAVG, DATEPART(dayofyear,…
-
0
votes1
answer53
viewsTurn rows into columns in SELECT Oracle
Below is a select for data query in a table: SELECT 'OS:'||AT.CD_NUMERO_OS ||' ITEM:'|| AT.ITEM ||' ETAPA DA ATVD:'||AT.CD_ETAPA_ATIVID||' ATVD:'|| AT.CD_ATIVIDADE AS "DADOS DA OS", AT.DT_INICIO AS…
-
0
votes2
answers33
viewsHow to search multiple columns together with max() SQL (Mysql)
The problem is this, I have the tables protocolo and historico; second stores several records linked to a record of the protocol table. I wanted to fetch the last record of each historical for…
-
0
votes0
answers36
viewsHow can I add values from a table using a date as a parameter?
I am trying to add some values of a table taking a date into consideration in sql. I want to add up the values until it reaches a date and a value greater than or equal to the initial value. An…
-
0
votes1
answer18
viewsHow to make row values return as columns in a select in Oracle?
The select I made is returning conforms example below: Select: SELECT Count(*) AS total,b."Nome",a."Funcionalidade", DECODE(a."Funcionalida", 128, 'ProdutoA', 4, 'ProdutoB', 512, 'ProdutoC' ) tipo…
-
0
votes1
answer28
viewsTake an input value and play value in another input by Javascript
Good evening, I would need the user to choose how many classes you want in select and then the system will calculate the value and put in the other input, I don’t know where I’m going wrong if you…
-
0
votes0
answers27
viewsOptimize Mysql query with Sub Select
I was having a problem of slowness in a select as below: select vendas.codigo, vendas.cartao_tipo, vendas.valor, vendas.datavenda, venda.autorizacao, cliente.codigo, cliente.nome, cliente.cpf,…
-
0
votes0
answers17
viewsTypeorm filter columns that have been transformed
I used the typeorm-Encrypted, to encrypt columns containing sensitive application data via the parameter Transformer as shown below: @PrimaryColumn() protocolo: number; @Column({ nullable: false,…
-
0
votes0
answers32
viewsMYSQL - How to Filter the Output of a main Select that has as one of the fields the result of a subquery?
Good afternoon Srs, this is my first post here, but I’m always researching the posts and the doubts of the people. I have the following situation: I CAN get all results, but I cannot FILTER what I…
-
0
votes2
answers40
viewsConsultation with Count
I have the following table : Product status SELECT id_produto_status_history, status, description, create_date, id_produto FROM produto_status_history; where I store product history status There is…
-
0
votes1
answer37
viewsHow to use SUM in a multi-return code?
I did it in a code where it makes a sum of data entered in the months, but I don’t know how to make the AS become a array. The Code I made: DECLARE @I INT = 1; WHILE @I < 12 BEGIN SELECT…
-
0
votes0
answers16
viewsMYSQL ERROR #1442 - Delete with a data-based Function of a select
I was trying to remove repeated values from a table, I needed a group by and a limit, I could only think using an extra Function: DROP FUNCTION IF EXISTS func; DELIMITER // CREATE FUNCTION…
-
0
votes0
answers13
viewsSELECT of two fields in the same table, prioritizing one field, but showing both
Hello, I have a bill release table to pay. There are fields like: data_de_lancamento, data_de_pagamento, data_pagamento_feito. What happens is that, in the query, I need for example: EX: I launched…
-
-1
votes1
answer638
views -
-1
votes1
answer111
viewsHow to make an SQL do the correct property count under certain criteria
I have the following SQL that correctly counts the number of properties: select clientes.id, clientes.nome, clientes.status, clientes.cliente, clientes.tipo, clientes.disponibilidade, imoveis.id,…
-
-1
votes2
answers543
viewsAssign value to SQL variable
How do I make one select which assigns the value "10" in all of the games column? Note: Without giving update on the table. /*minha_tabela*/ codigo jogos --------------------- 1 10 2 10 3 10 4 10 5…
-
-1
votes1
answer51
viewsSelect with most messaging users
I’m making a system and I have to know which user sent the most messages. My tables are more or less like this: User id|nome|sobrenome|email| ... Messages id|uid|nome|email|assunto|msg| ... I just…
-
-1
votes2
answers547
viewsSearch ID in a PHP select
<select class="form-control" name="cliente"> <?php if ($clientes) { foreach($clientes as $ind => $valor) { ?> <option value="<?php echo $valor->nome ?>"><?php echo…
-
-1
votes1
answer353
viewsSql in Postgresql: Do Not Repeat Values from a Table field
I have a select that displays the names, date and amounts paid by customers. I must display a list without repeating the names. SELECT c.name, p.created_at, p.amount_paid FROM payments as p, clients…
-
-1
votes2
answers62
viewsDoubt with select in if
Good afternoon I was trying to adapt a code I already had here so I could put a watermark on a photo. But it’s been a long time since I’ve done html or php. So, you could give me this help to fix…
-
-1
votes1
answer632
views -
-1
votes1
answer201
viewsMake a select with 3 tables and return in table 3 the id records of the first
I have three tables, the first is occurrence, the second is to individuals and third vehicles. The individual tables and vehicles I made occurrences subformularios. I have the first key in the…