Questions tagged as 'sql'

2
answers

Use result of SELECT as table name for another SELECT

I have a table of the following style Father |----|------- |-------| | id | precio | tabla | |----|------- |-------| |1 | 50 | sxt | |----|------- |-------| |2 | 45 | ext | |----|------- |-------| then I have other tables...
asked by 29.08.2017 / 00:29
2
answers

Merge record of one table with SUM of another for each record

As part of my database I have 2 tables (clients and loans), of which I am interested in operating with the following fields: LOANS: (Customer ID, Loan Amount) CLIENTS: (Customer ID) Consider that a client can have several loans....
asked by 08.09.2017 / 05:23
2
answers

Create a table if the database exists, if not create it in another database

I want to verify if there is a database BDDATOS1, if it exists I create a table in this database BDDATOS1, otherwise I create a table in database BDDATOS2. When I run the following IF EXISTS(SELECT * FROM master.dbo.SYSDATABASES WHERE NA...
asked by 26.08.2017 / 18:30
1
answer

Condition sums of a select

I have a table with the following structure: codigo / periodo / signo / importe I want to get the following: codigo / saldo_anterior / cargo_actual / abono_actual / saldo The period field is integer (YYYYMM) If for example I am in the...
asked by 09.11.2017 / 17:45
1
answer

Between with null fields

Good day I have a table where I have to make a query between two columns of type date, the problem is that the end date column can have null data, is there any way to perform the query ??? Here my query SELECT ACC INTO OUT_M1_PRIMNIV...
asked by 09.11.2017 / 18:46
1
answer

trigger and mutant table

I am having problems updating the rows of a table due to a necessary trigger that I have. The error is that of the mutant tables and I do not know how to modify my trigger so that it does not happen. The structure of the table is as follows:...
asked by 05.08.2017 / 03:24
1
answer

Constraint null and dni

I need a constraint that allows only the values NULL or a valid DNI (from Spain) to be inserted. I do not know how to add the one that is also worth the null value, I leave my constraint to see if they can finish it. Thanks. ALTER T...
asked by 04.08.2017 / 23:59
1
answer

Problem when displaying data

I have this script at the moment of executing it shows me error Tables: Controller $menu=DB::table('menu') ->select('menu','url','id_menu')->get(); $submenu=DB::table('sub_menu')->join('menu','...
asked by 09.08.2017 / 23:14
1
answer

Trigger hours every 30 m in oracle

I'm new to sql and I do not know how to address this problem. I have a table that stores citations with a atributo hora of type varchar2 . I need a trigger that avoid the insertion and update of hours that are not in the...
asked by 01.08.2017 / 19:32
2
answers

sql query that shows me all the clients and those that did not buy on a certain date replace with null

How can I show all the clients and if they did not buy on that date, change them to null? Enclosed consultation that shows me only the customers who bought on February 12, 2016 SELECT clienteid ,productoid , fechaorden FROM Ventas.Ordenes...
asked by 05.09.2017 / 07:31