Questions tagged as 'sql'

1
answer

PostgreSQL constraint error

I have a code that is giving the following error:    there is no unique constraint matching given keys for referenced table   "schedule" Code: CREATE TYPE weekday AS ENUM ('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sab...
asked by 13.02.2015 / 20:49
1
answer

How to set a default value created by the user when creating a table (SQL Server)?

I created a default value for my database: CREATE DEFAULT [dbo].[zero] as 0 However, I can not create a table using this default value. How do I set this value at the time of creating a table? For example: CREATE TABLE TESTE ( num int DEF...
asked by 02.12.2014 / 12:52
1
answer

How to mount a Select to join columns

I have a question that I do not even know if it is possible, it is as follows: I would like to perform a select that joins up two columns. Otherwise it would be: Table Person with the fields cod_people - name - rg - razao_social - cnpj C...
asked by 13.01.2015 / 00:51
1
answer

Decode in full select

Can I perform a decode on a select that returns all the data in a table and some of the other tables? In this select, I would like to do a decode for one of the columns of PP (request_peace), but as it does a full search I do not know if it i...
asked by 06.11.2014 / 20:26
3
answers

PostgreSQL Query - How to do this?

How do I do a SQL query on this table: ID Col2 Col1 -- ---- ---- 11 1 A 12 2 D 13 3 G 14 1 B 15 2 E 16 3 H 17 1 C 18 2 F 19 3 I To return this result: 1 A B C 2 D E F 3 G H...
asked by 24.02.2015 / 22:21
1
answer

Search function for Sql Server

I would like to know if it has a function or if it could be done with a select , the search by the email field of a table. Example: select PPESSOA.EMAIL from PPESSOA where PPESSOA.NOME like 'ABNER FONTOURA C,RÊA' 'ADAILTON PEREIRA DE SO...
asked by 26.11.2014 / 18:06
2
answers

Only select columns with values

I have a table with a sequence of fields with almost the same name, changing only the final character, and I need to make a query that returns only the columns with some value, I currently do the following: select pag, descricao,cod_vcto1,cod_v...
asked by 20.10.2014 / 19:37
2
answers

Run SQL files inside subdirectories on Linux

I have a repository of SQL files where each represents a stored procedure . These files are inside a directory organized in other subdirectories. Example of my directory structure: stored-procedures ---d1 ------sd1 ---------sp1.sql -------...
asked by 14.11.2014 / 11:38
1
answer

Use Left Join on Datatable Server-Side

After several attempts, I have not yet been able to implement a 100% left join within the Datatable Server-Side Please note, the following code works 100% HTML <table id="datatable_fixed_column" class="table table-striped table-border...
asked by 16.11.2014 / 03:23
1
answer

Rails 4 select Uniq

I have the Items table: id enrollment_id turma_id 11 2 2 12 2 3 13 2 2 14 2 2 15 2 3 I want my result to be this: id enrollment_id turma_id 11...
asked by 18.11.2014 / 18:21