Questions tagged as 'sql'

3
answers

It is possible to get data from the entire month in postgreSQL

How do I get all the data stored in the database from a specific month: I think you should pass the year / month as a parameter, for example, variable="2016/10"; remembering that the type of the data in the database and timestamp SELECT * FR...
asked by 20.10.2016 / 20:00
1
answer

Arbitrary Decimal Truncation with PostgreSQL

I am doing an SQL query using the sum() function. This function adds integers and fractional numbers. The problem is that it returns a double precision with a very large number. How do I limit to two decimal places after the point? C...
asked by 30.10.2016 / 18:54
2
answers

Create a column in Mysql that automatically divides the values into two other columns

I need to explain how I can make it similar to what happens in Excel I can create a column in Mysql that divides the values of the other two columns. Something like column 1 / column 2 = column 3. For example I have two columns and several ro...
asked by 01.04.2015 / 20:18
1
answer

How to do select in the bank involving foreign key and primary key?

I have a problem, I have two tables that are related to the foreign key and the primary key like this: CREATE TABLE IF NOT EXISTS cargo( id INT AUTO_INCREMENT NOT NULL, nome_cargo varchar(50) not null, "supervisor,gerente, etc..." sal...
asked by 04.04.2016 / 21:07
1
answer

Add Column on SQL server

I'm working on a system that needs to perform a sum that will be done in a SQL Server view. In C # I know how to solve this. I would like to resolve using SQL. ColA ColB 200911 1634,50 200911 558,29 200911 2446,66 200911 2860,90 200911...
asked by 29.11.2014 / 22:36
1
answer

Update sql with 2 conditions

I have a table with the STATUZ column This column consists of 3 possible values: NEW, VISUALIZED, DISCARDED I have a function where I need to implement a SQL row that updates my table and changes all the values in the STATUZ column to: D...
asked by 15.07.2015 / 23:39
2
answers

CURSOR vs table-type variable

I'm facing one of those situations where I need to perform an action for each row resulting from a query. In this way I have two options, to use a Cursor or a Table Variable , however the two seem to me very similar (semantically...
asked by 26.03.2015 / 20:37
1
answer

Concatenate columns and some with NULL value

I'm doing a select and concatenating the columns, when a column has value NULL (has no value) the entire line gets NULL follows an example: select 'teste'||CONTROLE||','||CODIGO||','||DATA||','||HISTORICO from tabela The res...
asked by 13.08.2015 / 15:47
1
answer

Search method involving Java and SQL Server

How to do a search in java passing an attribute of the (SQL) as parameter? I decided to type an outline of the cod: MAIN static private void PesquisarUsuario(Connection con) throws SQLException { int cpf; Scanner s = new Scanne...
asked by 15.05.2014 / 03:28
1
answer

Check if date is even or odd

I need help with dates in SQL Server. I have a date field and would like to know if this date is odd or even. I need to make this comparison to use in another field. I looked for some methods but I did not get the solution. I thought about us...
asked by 14.12.2018 / 12:44