Questions tagged as 'sql'

2
answers

How to give an INSERT of primary keys of an X table in a table Y

Hello, well, I'm having a hard time giving insert to the table, and I have two FK's that link the person table. My question is: How do I get the desired PK's and insert them as FK's? Split table: create table divida( codigo_divida int(5) pr...
asked by 05.11.2016 / 14:01
1
answer

How to compare a date of type datetime?

I have a date in a patient table in the Sql Server database in the following format: datetime (01/01/2016 12:50:00.000) I want to check if the patient's appointment time has arrived. For example: The time of the appointment is at 13:00...
asked by 30.10.2016 / 16:42
2
answers

Conversion of SQL Server types

I have the following SELECT in SQL Server: SELECT th.CidadeCod, th.ContratoCod, CONVERT(DECIMAL(5,2), ( SUM(th.PlacasLidas)/SUM(th.Trafego) ) * 100) AS [IndiceOCR] FROM controle.TrafegoFaixaHora th INNER JOIN ssis.Co...
asked by 21.10.2016 / 13:34
1
answer

How to search with a text variable containing apostrophes?

Problem When searching for 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 WHERE cidade = @cidade The abo...
asked by 21.10.2016 / 22:04
1
answer

MySQL Function returning NULL

My function does not work for anything in this world SQL looks like this: - Function used to return the remaining space of a chosen folder. - DELIMITER $$ CREATE FUNCTION tamanhoRestante (_idPasta INT) RETURNS INT BEGIN DECLARE lpas...
asked by 07.11.2016 / 15:36
1
answer

Select the most repeated data in a column and display them

Good evening, I'm on a project where I have to make a site that allows users to recommend movies, and then show them the most recommended ones. I've already done the recommend system, now I need to make the most recommended list. The syste...
asked by 27.09.2016 / 04:23
1
answer

How to select greater number of records based on another SQL table

I have an IMOVEIS table ID | Tipo | endereço 1 | Casa | Rua teste 2 | Casa | Rua teste 3 | Apartamento | Rua teste And a sales table id | ID_do imovel 1 | 1 2 | 2 I need to know based on the sales chart, wh...
asked by 26.09.2016 / 14:21
1
answer

Enter data in the Mysql database received from a Json

I have the following problem, I have an app and by it send some data in the format Json, for the server, up to that blz, arrives in this good format: {"credenciador":"","evento":"16","inscrito":[{"id_inscrito":"13","data_credenciado":"2016-0...
asked by 26.09.2016 / 20:53
1
answer

Insert range of numbers into a table automatically SQL

The question is the following I want to insert in a field of a table a range of numbers that goes from 100 to 1 000 000 000 and did not want to be doing 1 to 1. How can I do this automatically? In SQL Server     
asked by 03.10.2016 / 13:15
3
answers

Delete Report with months reset

I have a query in which I take monthly deposited values, it takes everything that it has in the base and shows the months that were inserted in the database. I would like to do different would like it to also show the months that did not have...
asked by 08.11.2016 / 16:19