Questions tagged as 'sql'

1
answer

How to join the two tables in this case?

I have two tables one "students" with enrollment and enrollment and another "do" with the students' grades in certain tests. I used the pivot command in the table "do_test" to transform the name of the tests into columns and the notes in lines,...
asked by 19.02.2016 / 19:21
0
answers

Convert sql to eloquent

How can I convert this code sql into eloquent ? SELECT CONCAT(FLOOR(sum(diferenca)/60),'h',MOD(sum(diferenca),60),'m') as tempo FROM (SELECT TIMESTAMPDIFF(MINUTE, m1.created_at, min(m2.created_at)) as diferenca FROM me...
asked by 04.08.2018 / 19:35
1
answer

Help with GROUP_CONCAT (MySql)

I would like to use grupo_concat for filename and answer but would not repeat the values of filename and answer Follow sqlfiddle: link It is a question that has 2 images and 4 alternatives of A-D....
asked by 03.08.2018 / 21:21
1
answer

remove zeros sql [closed]

I have a EUW0 field 10598260, and needed to be EUW 1598260 I need to remove a specific field SQL: SELECT 'EUW' + substring(campo,patindex('%[^EUW0 ]%',campo + ' ') ,len(campo)) AS campo1 ,campo2 FROM [tabela] WHERE...
asked by 15.01.2016 / 12:59
1
answer

Number of rows increases after use of JOIN

Hello, I'm new to SQL and am having a question. As in the example below, I wanted to get a description of the code in the 'a' table from a table 'b'. But the number of rows in table 'a' when I do this increases significantly. select a.banana,...
asked by 11.08.2016 / 00:30
2
answers

ORA-22922: nonexistent LOB value in SELECT

I'm facing a problem with two separate queries in oracle . Both have the sql% share of% The error that returns is REPLACE(dbms_lob.substr(wm_concat(disctinct <COLUNA>)), ',', ', ') . I looked for the error in ORA-22922...
asked by 11.04.2016 / 22:24
2
answers

How to delete the first line of a megapesado SQL file?

I have a "mega-heavy" SQL file that does not open either in sublime, in notepad or in gedit. I just need to delete the first line Use nome_database; to be able to import through the workbench or mysql command line in the terminal: mys...
asked by 18.04.2016 / 19:41
1
answer

Switch lines by columns

Hello, I have the following query: set NOCOUNT on; declare @_mes int = 2 declare @_ano int = 2016 declare @_dataini datetime = CONVERT(DATETIME, '01/' + REPLICATE('0', 2 - LEN(@_MES)) + CAST(@_MES AS VARCHAR(2)) + '/' + CAST(@_ANO AS VARCHA...
asked by 02.03.2016 / 15:34
3
answers

2 COUNT within a SELECT with LEFT JOIN

I have two tables: Users: id | nome | email submissions: id | id_envia | id_recebe Every time a user sends a card (which goes by email) to another user, it marks this table, and every time it receives a tag as well. Doubt: I...
asked by 09.03.2016 / 20:52
1
answer

SQL statement error

I have the following DB: WhenIrunthefollowingQuery:SELECTtbCelula.*FROM(((tbTiposMonitorizacaoINNERJOINtbMonitorizacaoProjONtbTiposMonitorizacao.TM_ID=tbMonitorizacaoProj.MP_T_ID)INNERJOINtbListaConformidadesONtbMonitorizacaoProj.MP_ID=tbListaC...
asked by 11.12.2015 / 11:28