I am a beginner. More than problems, I have ideas I share my code ;D. NO RULES

18 views Asked by At

This could be a good structure? , because i try to combine 2 differents ideas Students and other bd This query obtains information about students and the courses in which they are enrolled. A combination of tables (Students, Enrollments and Courses) is used through INNER JOIN clauses to relate students to the courses in which they are enrolled.

SELECT 
    Estudiantes.Nombre AS NombreEstudiante,
    Estudiantes.Apellido AS ApellidoEstudiante,
    Cursos.Nombre AS NombreCurso,
    Cursos.Codigo AS CodigoCurso
FROM 
    Estudiantes
INNER JOIN 
    Matriculas ON Estudiantes.ID = Matriculas.EstudianteID
INNER JOIN 
    Cursos ON Matriculas.CursoID = Cursos.ID;
CREATE TABLE Facturas (
    FacturaID INT PRIMARY KEY IDENTITY,
    BaseImponibleIVA0 DECIMAL(18, 2) NOT NULL,
    BaseImponibleIVA12 DECIMAL(18, 2) NOT NULL,
    IVA DECIMAL(18, 2) NOT NULL,
    TotalPagar DECIMAL(18, 2) NOT NULL
);

CREATE TABLE TiposIVA (
    ID INT PRIMARY KEY,
    Descripcion NVARCHAR(50)
);
INSERT INTO TiposIVA (ID, Descripcion) VALUES (1, 'SELECCIONE');
INSERT INTO TiposIVA (ID, Descripcion) VALUES (0, 'IVA 0%');
INSERT INTO TiposIVA (ID, Descripcion) VALUES (12, 'IVA 12%');

EMPEZANDO EN ESTE MUNDO XD 

Herramienta (Tool) > Nuggets quete managmente > Administrar paquetes de nuggets para la solucion 
Examinar itextshap 
Luego de instalarlo y ver nuestra BDD vamos a referencia y la veremos

alter PROCEDURE ObtenerTiposIVA
AS
BEGIN
    SELECT ID, Descripcion
    FROM TiposIVA
    ORDER BY CASE WHEN Descripcion = 'SELECCIONE' THEN 0 ELSE 1 END, Descripcion;
END;

ALTER PROCEDURE InsertarFactura
(
    
    @BaseImponible0 DECIMAL,
    @BaseImponible12 DECIMAL,
    @IVA DECIMAL,
    @TotalPagar DECIMAL
)
AS
BEGIN
    INSERT INTO Facturas ( BaseImponibleIVA0, BaseImponibleIVA12, IVA, TotalPagar)
    VALUES ( @BaseImponible0, @BaseImponible12, @IVA, @TotalPagar);
END;
0

There are 0 answers