Questions tagged as 'sql'

1
answer

Relationship (Database) (Sql)

please: I can not understand the following case: My problem would be the syntax used in part (1,1) - (1, N) In case it would be, 1 Department lota N employees and 1 Employee can be in only 1 department. So far so good, but the cardin...
asked by 12.04.2017 / 00:00
1
answer

mysql error with foreign key

I'm creating a modeling but I'm stumbling on an error when I create foreign keys. MYSQL gives a "Can not add foreign key constraint" error. follow my sql. use fatec; create table aluno( ra int not null primary key, nome varchar(255), cida...
asked by 04.09.2016 / 01:37
3
answers

How to remove duplicate data in this query? [duplicate]

Hey blz personal? Next I'm using this query: select products.id as product_id, offers.id as offer_id, companies.id as company_id, products.title, (ST_Distance(companies.location, 'POINT(-48.030322 -15.839689)':: g...
asked by 02.09.2016 / 18:32
1
answer

Bug script to delete the entire SQL SERVER database

I have the following script to drop EVERYTHING from the database, but in one of the database I have the processing that needs this script a bug happens, for some reason it can not run the first time I run, but in second wheel without any hindran...
asked by 19.12.2016 / 16:54
2
answers

Stored Procedure for inserting log data

I need to create a Stored Procedure in my SQL Server database. The purpose of this Stored Procedure is to write data to a Log table, which has three fields: date, time, login ID. Date and time would be the time of login, while the Login ID co...
asked by 29.02.2016 / 13:14
0
answers

Search in sql server 2014 with php

I am using Sql Server Express, I have an instance installed in two virtual machines on the server, one of the installed instances is Sql Server 2008 , and the other is the Sql Server 2014 When executing the same query in both instances I h...
asked by 21.06.2016 / 01:27
1
answer

Problem generating report between dates

I have a DATETIME field with a date and time: 2015-08-06 08:50:28 . I'm trying to generate a report by passing two parameters, Data_Inicial and Data_Final so I can get all the bank dates that are in that period. The condi...
asked by 06.08.2015 / 14:39
1
answer

Problems with select in multiple tables

I'm trying to do the conversion from a select sql server to the Dapper, as it was too big, I'm wanting to make it leaner and readable ... But this error appearing in some parts SELECT email.assunto [Assunto], disp.cod_disparador [Dispa...
asked by 19.09.2016 / 17:46
2
answers

How can I count fields that are NULL?

I'm using this query: I would like to know how I can count these fields that have no records. Here it returns 0. But I have some null records. What do I do? SELECT DataFim, COUNT(DataFim) AS QTD FROM AtivacaoGuincho GROUP BY DataFim HAVING Dat...
asked by 26.01.2017 / 18:00
4
answers

Find the best-selling item together with a certain item [duplicate]

To explain, I prefer an example: I want to find out which item is best sold along with salted chicken. For this, I tried the following approach and failed miserably due to lack of technical knowledge: -Find all coupons (sales) that...
asked by 04.08.2017 / 07:06