Questions tagged as 'sql'

3
answers

Update in two columns, two tables

I have to update two columns in separate tables, but I do not know the commands very well, I would not like to use triggers. Will be updated around 100 records. Here is an example: Table a id nomes nota 1 SOen etc1...
asked by 15.06.2014 / 00:25
2
answers

Using the PIVOT operator without aggregation

I have the FAULTS table with the following columns: CREATE TABLE [dbo].[FALTAS]( [Id] [int] IDENTITY(1,1) NOT NULL, [Matricula] [int] NOT NULL, [Dia] [date] NOT NULL, [Situacao] [varchar](50) NOT NULL, CONSTRAINT [PK_FALTAS] PRIMARY KEY CLUSTE...
asked by 21.06.2014 / 19:19
2
answers

SQL Grouping by name, date and quantity per month

I am not able to group this resulting per month (FIELD "PP.PAPELETA_DATA"). Type the amount (count (PD.PessoaId) as Total) separated per month! Could someone give me a help? Use SQL SERVER 2012. SELECT PE2.PessoaNome, count(PD.PessoaId) as To...
asked by 14.02.2015 / 23:54
1
answer

How to add unmatched parcels with SQL?

I have 3 tables faturas , parcelas and pagamentos . Now I need to mount an SQL to count the parcels that are not removed. I already tried SUM(CASE but it did not work. Structure of the faturas table: id_fa t...
asked by 24.01.2016 / 13:56
3
answers

List calculated dates per month based on parameters

Based on two dates received per parameter, I am trying to list all the dates per month (one date per month) based on the start date and until the end date. These returned dates must check which day of the week of the start date and the number of...
asked by 30.03.2016 / 17:12
3
answers

SELECT in a RELATIONSHIP WITH SELF-RELATIONSHIP (Checking for Occurrences)

I'm having a hard time making an appointment. The situation is as follows, I need the bank to return all names of courses that have no prerequisites and are not prerequisites. The relationship is this: /* Create a table */ CREATE TABLE DISC...
asked by 25.11.2015 / 18:39
1
answer

Help with SQL to search for planes that have already done all the routes

Imagining that there are 3 planes (A, B, C) and 5 routes and the inserts (A-1; B-2,4,5; C-1,2,3,4,5), I want to select only the planes that have already made flights in all the routes, in this case the C (C-1,2,3,4,5). I have experimented in...
asked by 25.11.2015 / 21:36
2
answers

SUM in SELECT with LEFT JOIN being multiplied together

I have 3 tables in MYSQL. Account: id nome 1 caio 2 zé 3 marcelo Followers (the account id, that is, the user has 2 followers): idqual 1 1 2 2 2 3 Products (the account id, that is, the user caio has 3 products): idqual 1...
asked by 21.09.2015 / 21:27
1
answer

Sending data from one table to another with the deleted command

I'm creating this trigger in SQL Server , but I'm not getting the id to send the data to another table and delete this table. CREATE TRIGGER MoveComprador ON comprador INSTEAD OF DELETE AS BEGIN SELECT * INTO bk_comprador FROM...
asked by 19.06.2015 / 06:31
1
answer

Model Entity Relationship: Ternario vs Agregação?

Assuming I have a ternary relationship: two entities are NxN and the third entity is weak in relation to the relationship between these two. I would like to know the difference between creating an aggregation between the two NxN entities and...
asked by 15.10.2015 / 03:46