Questions tagged as 'sql'

1
answer

Can you use logic operators with CASE / WHEN?

I'm trying to use logical operators with CASE / WHEN in SQL but I'm having difficulties, I need to give a response in case the result of the operation is less than 0 and another result for when the operation is > = 0 It makes a mistake if...
asked by 12.02.2018 / 19:46
2
answers

Invert id string into a table

I had to migrate a site that was made in pure PHP to Wordpress, searched the internet and managed to copy the data from the old site table to the Wordpress structure, that one thing happened, all the news was copied from behind to front, then wh...
asked by 04.05.2018 / 02:08
2
answers

How to get the sum of an entire column in SQLSERVER

I need to get the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithe is required. ex: total = VOL (7.6890028) - > sum of the 4 lines of column VOL...
asked by 03.05.2018 / 21:56
1
answer

Query in two tables

Well, how do I query on two tables in sql? For example, I have a Company table with the id , ravelosocial and cnpj fields. I also have another table, Branch with the fields id , address , company_id . I want to do a select of the fir...
asked by 01.06.2018 / 00:09
1
answer

How to sort a date that is in varchar format?

I have the following select: SELECT a.nome, a.cidade, a.telefone, a.dt_criado FROM cadastro AS a GROUP BY a.nome, a.cidade, a.telefone, a.dt_criado HAVING COUNT(*) > 0 ORDER BY a.dt_criado DESC a.dt_create...
asked by 03.05.2018 / 21:43
2
answers

Exchange Tag for another SQL Tag

I have the following email: [email protected] , I need to change everything that has meusite.com.br to seusite.com.br . How can I do it? My idea was: UPDATE tabela SET email = email "seusite.com.br" .. But then...
asked by 01.03.2018 / 18:47
1
answer

UPDATE WITH CASE SQL

Is there any way I can use more than one column of the same table in a case statement in an update? for example, I have this table with these 3 lines create table produto2( codigo int primary key, categoria varchar(30), valor number(7,2)); in...
asked by 16.05.2018 / 02:03
2
answers

What is the best type of column to record amount of time?

We usually use DateTime to record a specific moment. But what if I want to record that an event lasted half an hour (00:30) or an hour and a quarter (01:15)? I thought of converting to decimal, so the input of 01:15 by the user would have t...
asked by 17.07.2014 / 14:26
3
answers

Transform DD / MM / YY into PHP timestamp

I need the user to enter a date and this date is sent to the database as timestamp, example Insert: 25/12/17 in the field I want to get to the database as 1514160000 which means "Mon, 25 Dec 2017 00:00:00 GMT" I have not tried anyth...
asked by 08.11.2017 / 18:38
2
answers

Set of WHERE, AND, and OR Conditions in SQL does not produce the expected result

I'm trying to get some records with a very simple syntax, but it's not working. I'm doing something wrong and I'm not realizing it. Can someone lend a hand? I need to fetch all 2017 records except FREIGHT AND TAXES! I have this: SELECT * F...
asked by 30.06.2017 / 18:11