Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Generate all combinations for variables and insert into temp table

I have one requirement there are 4 variables and i want all combinations of 4 variables and insert into temp table .

DECLARE StartDateTime DATETIME;
DECLARE Age INT; 
DECLARE Duration INT ;
DECLARE TotalDD INT;

CREATE TEMPORARY TABLE tempTable(
    Duration INT,
    TotalDD INT,
    Age INT,
    StartDateTime DATETIME,
   
);
SET Age = 16;
SET TotalDD = 14;
SET Duration = 30;
SET StartDateTime = CURDATE();

Excepted Result:

Duration age TotalDD StartDateTime
30 null null null
null 16 null null
30 null null null
30 16 null null
null null 14 20200622
30 null 14 null
30 16 null 20200622

........... .......... so on

please help me on this

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think you want a cross join:

select *
from (select 16 as age union all select null) a cross join
     (select 14 as totaldd union all select null) t cross join
     (select 30 as duration union all select null) d cross join
     (select CURDATE() as StartDateTime union all select null) s
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda