Skip to main content
adicionou 207 caracteres ao conteúdo
Fonte Link
Tiedt Tech
  • 2,4mil
  • 4
  • 22
  • 47

CREATE TABLE PFFINANC ( CODCOLIGADA INT NOT NULL, CHAPA VARCHAR (4) NOT NULL, ANOCOMP SMALLINT NOT NULL, MESCOMP SMALLINT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, VALOR RMDVALOR2 NULL, )

SQL de Criação

CREATE TABLE dbo.ZMDCUSTO_PESSOAL ( CODCOLIGADA INT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, RD1 BIT NULL, RD2 BIT NULL, RD3 BIT NULL, RD4 BIT NULL, RD5 BIT NULL, RD6 BIT NULL, RD7 BIT NULL, RD8 BIT NULL, RD9 BIT NULL, RD10 BIT NULL, RD11 BIT NULL, RD12 BIT NULL, RD13 BIT NULL, RD14 BIT NULL, RD15 BIT NULL, RD16 BIT NULL, RD17 BIT NULL, RD18 BIT NULL, RD19 BIT NULL, RD20 BIT NULL, RD21 BIT NULL, RD22 BIT NULL, RD23 BIT NULL, RD24 BIT NULL, RD25 BIT NULL, RD26 BIT NULL, RD27 BIT NULL, RD28 BIT NULL, RD29 BIT NULL, RD30 BIT NULL, RECCREATEDBY VARCHAR (50) NULL, RECCREATEDON DATETIME NULL, RECMODIFIEDBY VARCHAR (50) NULL, RECMODIFIEDON DATETIME NULL, PRIMARY KEY (CODCOLIGADA, CODEVENTO) )

CREATE TABLE PFFINANC
(
    CODCOLIGADA       INT  NOT NULL,
    CHAPA             VARCHAR (4) NOT NULL,
    ANOCOMP           SMALLINT NOT NULL,
    MESCOMP           SMALLINT NOT NULL,
    CODEVENTO         VARCHAR (4) NOT NULL,
    VALOR             RMDVALOR2 NULL,
)


    

CREATE TABLE dbo.ZMDCUSTO_PESSOAL
(
    CODCOLIGADA   INT NOT NULL,
    CODEVENTO     VARCHAR (4) NOT NULL,
    RD1           BIT NULL,
    RD2           BIT NULL,
    RD3           BIT NULL,
    RD4           BIT NULL,
    RD5           BIT NULL,
    RD6           BIT NULL,
    RD7           BIT NULL,
    RD8           BIT NULL,
    RD9           BIT NULL,
    RD10          BIT NULL,
    RD11          BIT NULL,
    RD12          BIT NULL,
    RD13          BIT NULL,
    RD14          BIT NULL,
    RD15          BIT NULL,
    RD16          BIT NULL,
    RD17          BIT NULL,
    RD18          BIT NULL,
    RD19          BIT NULL,
    RD20          BIT NULL,
    RD21          BIT NULL,
    RD22          BIT NULL,
    RD23          BIT NULL,
    RD24          BIT NULL,
    RD25          BIT NULL,
    RD26          BIT NULL,
    RD27          BIT NULL,
    RD28          BIT NULL,
    RD29          BIT NULL,
    RD30          BIT NULL,
    RECCREATEDBY  VARCHAR (50) NULL,
    RECCREATEDON  DATETIME NULL,
    RECMODIFIEDBY VARCHAR (50) NULL,
    RECMODIFIEDON DATETIME NULL,
    PRIMARY KEY (CODCOLIGADA, CODEVENTO)
)

CREATE TABLE PFFINANC ( CODCOLIGADA INT NOT NULL, CHAPA VARCHAR (4) NOT NULL, ANOCOMP SMALLINT NOT NULL, MESCOMP SMALLINT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, VALOR RMDVALOR2 NULL, )

CREATE TABLE dbo.ZMDCUSTO_PESSOAL ( CODCOLIGADA INT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, RD1 BIT NULL, RD2 BIT NULL, RD3 BIT NULL, RD4 BIT NULL, RD5 BIT NULL, RD6 BIT NULL, RD7 BIT NULL, RD8 BIT NULL, RD9 BIT NULL, RD10 BIT NULL, RD11 BIT NULL, RD12 BIT NULL, RD13 BIT NULL, RD14 BIT NULL, RD15 BIT NULL, RD16 BIT NULL, RD17 BIT NULL, RD18 BIT NULL, RD19 BIT NULL, RD20 BIT NULL, RD21 BIT NULL, RD22 BIT NULL, RD23 BIT NULL, RD24 BIT NULL, RD25 BIT NULL, RD26 BIT NULL, RD27 BIT NULL, RD28 BIT NULL, RD29 BIT NULL, RD30 BIT NULL, RECCREATEDBY VARCHAR (50) NULL, RECCREATEDON DATETIME NULL, RECMODIFIEDBY VARCHAR (50) NULL, RECMODIFIEDON DATETIME NULL, PRIMARY KEY (CODCOLIGADA, CODEVENTO) )

SQL de Criação

CREATE TABLE PFFINANC
(
    CODCOLIGADA       INT  NOT NULL,
    CHAPA             VARCHAR (4) NOT NULL,
    ANOCOMP           SMALLINT NOT NULL,
    MESCOMP           SMALLINT NOT NULL,
    CODEVENTO         VARCHAR (4) NOT NULL,
    VALOR             RMDVALOR2 NULL,
)


    

CREATE TABLE dbo.ZMDCUSTO_PESSOAL
(
    CODCOLIGADA   INT NOT NULL,
    CODEVENTO     VARCHAR (4) NOT NULL,
    RD1           BIT NULL,
    RD2           BIT NULL,
    RD3           BIT NULL,
    RD4           BIT NULL,
    RD5           BIT NULL,
    RD6           BIT NULL,
    RD7           BIT NULL,
    RD8           BIT NULL,
    RD9           BIT NULL,
    RD10          BIT NULL,
    RD11          BIT NULL,
    RD12          BIT NULL,
    RD13          BIT NULL,
    RD14          BIT NULL,
    RD15          BIT NULL,
    RD16          BIT NULL,
    RD17          BIT NULL,
    RD18          BIT NULL,
    RD19          BIT NULL,
    RD20          BIT NULL,
    RD21          BIT NULL,
    RD22          BIT NULL,
    RD23          BIT NULL,
    RD24          BIT NULL,
    RD25          BIT NULL,
    RD26          BIT NULL,
    RD27          BIT NULL,
    RD28          BIT NULL,
    RD29          BIT NULL,
    RD30          BIT NULL,
    RECCREATEDBY  VARCHAR (50) NULL,
    RECCREATEDON  DATETIME NULL,
    RECMODIFIEDBY VARCHAR (50) NULL,
    RECMODIFIEDON DATETIME NULL,
    PRIMARY KEY (CODCOLIGADA, CODEVENTO)
)
Fonte Link

Separar Colunas em Numeros de Linhas SQL

to com um problema para SQL Server.

Tenho uma tabela de evento e valor e faço um join com uma outra tabela que tem varias colunas, podendo a verba ser marcada como 1 para ativo e 0 inativo.

Como pode ver na imagem a linha 1 tem o RD8 , RD10 e RD21 marcados, queria que o valor de 97,24 fosse demonstrado em linhas porem somente para os RD's marcados.

inserir a descrição da imagem aqui

Ela Teria que ficar assim.

inserir a descrição da imagem aqui

CREATE TABLE PFFINANC ( CODCOLIGADA INT NOT NULL, CHAPA VARCHAR (4) NOT NULL, ANOCOMP SMALLINT NOT NULL, MESCOMP SMALLINT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, VALOR RMDVALOR2 NULL, )

CREATE TABLE dbo.ZMDCUSTO_PESSOAL ( CODCOLIGADA INT NOT NULL, CODEVENTO VARCHAR (4) NOT NULL, RD1 BIT NULL, RD2 BIT NULL, RD3 BIT NULL, RD4 BIT NULL, RD5 BIT NULL, RD6 BIT NULL, RD7 BIT NULL, RD8 BIT NULL, RD9 BIT NULL, RD10 BIT NULL, RD11 BIT NULL, RD12 BIT NULL, RD13 BIT NULL, RD14 BIT NULL, RD15 BIT NULL, RD16 BIT NULL, RD17 BIT NULL, RD18 BIT NULL, RD19 BIT NULL, RD20 BIT NULL, RD21 BIT NULL, RD22 BIT NULL, RD23 BIT NULL, RD24 BIT NULL, RD25 BIT NULL, RD26 BIT NULL, RD27 BIT NULL, RD28 BIT NULL, RD29 BIT NULL, RD30 BIT NULL, RECCREATEDBY VARCHAR (50) NULL, RECCREATEDON DATETIME NULL, RECMODIFIEDBY VARCHAR (50) NULL, RECMODIFIEDON DATETIME NULL, PRIMARY KEY (CODCOLIGADA, CODEVENTO) )