Questions tagged as 'sql'

2
answers

Why does To_char (3E4) not result in '3E4'?

How do I convert an exponential number (NUMBER) to string (VARCHAR) but which is expressed equal to? Example: SQL> SELECT TO_CHAR (NUMERO) NUMCONVERT 2 FROM (SELECT 3E4 NUMERO FROM DUAL); NUMCONVERT --------------------------...
asked by 13.04.2017 / 18:37
1
answer

Why create a table in MySQL?

I'm learning how to work with MySQL and I'm looking at some examples of how to work with more than one table, as an example below: Id Nome Faculdade_id 101 Amanda 11 102 Bianca 12 103 Carla 13 104 Da...
asked by 03.04.2017 / 21:29
2
answers

How to use Sum with subquery

How can I use sum with a subquery inside? I tried in many ways, but I could not. When I try to put sum right after the main select , I get the message that I can not use aggregate function with aggregate or query. SELECT SUM(CONVE...
asked by 20.02.2017 / 12:38
1
answer

PDO Insert multiple row in same insert using bindParam

I have a default function that I use for all my inserts (when they only have 1 insert at a time), which would be: insereRegistro($sql, $param=NULL) { $query = $conn->prepare($sql); //Converte os parâmetros para bindParam if ( i...
asked by 06.01.2017 / 13:18
3
answers

Group date periods

I need to do a query that returns all records grouped in certain periods. The table contains a date type and should produce output similar to this: | Hora | Quantidade | ------------------------- 01 | 08:00 | 30 | 02 | 08:05 | 28...
asked by 10.11.2016 / 13:38
2
answers

Query values with 0 included in count () even if they do not have values

I need to check the number of notes issued with template 55 to create a report. The problem is that I'm having to put zero values in the quantity column even though they have no value at all. Ex: empresa filial data quantidade 5...
asked by 13.12.2016 / 12:53
1
answer

Sql server transform a column into several rows

Good morning I have a table called books that has 3 fields, Code, Name and Chapters Example content: 32 - Jonas - 4 I need that after the select return the following result to me Codigo e Capitulo 32 1 32 2 32 3 3...
asked by 02.02.2017 / 10:51
2
answers

How to do paging in SQLServer 2008 R2? [duplicate]

I tested it in two ways, but I did not succeed. select * from table OFFSET 10 ROWS select top 10 * from table OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY Strangely enough I've never needed to use offset in this version of SQLServer, and now I'...
asked by 22.08.2017 / 21:09
1
answer

How to turn this query into a JPQL?

I have the following query in the postgres database: select * from trabalha_projeto tp inner join Empregado e on e.matricula = tp.empregado How does it transform it into a JPQL query? I'm having a hard time returning values: First: not...
asked by 05.04.2016 / 03:33
1
answer

SQL is importing dates in different format

I'm having problems when I select a date column in SQL Server. It turns out that my data is in the dd/mm/aaaa format and when I select that column the SQL inverts getting aaaa-dd-mm and in fact it would have to be aaaa-mm-dd...
asked by 13.10.2015 / 14:26