Pular para conteúdo

Home

Calculando o signo

SELECT 
    ,a.nascimento
    ,STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',MONTH(a.nascimento),'-',DAY(a.nascimento)), '%Y-%m-%d') AS DATA_nova

    ,case 
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',1,'-',21), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',2,'-',18), '%Y-%m-%d') then 'aquario'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',2,'-',19), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',3,'-',20), '%Y-%m-%d') then 'peixes'

        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',3,'-',21), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',4,'-',20), '%Y-%m-%d') then 'aries'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',4,'-',21), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',5,'-',20), '%Y-%m-%d') then 'touro'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',5,'-',21), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',6,'-',20), '%Y-%m-%d') then 'gemeos'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',6,'-',21), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',7,'-',22), '%Y-%m-%d') then 'cancer'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',7,'-',23), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',8,'-',22), '%Y-%m-%d') then 'leao'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',8,'-',23), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',9,'-',22), '%Y-%m-%d') then 'virgem'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',9,'-',23), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',10,'-',22), '%Y-%m-%d') then 'libra'
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',10,'-',23), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',11,'-',21), '%Y-%m-%d') then 'escorpiao'      
        when a.nascimento BETWEEN STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',11,'-',22), '%Y-%m-%d') AND STR_TO_DATE(CONCAT(YEAR(a.nascimento),'-',12,'-',21), '%Y-%m-%d') then 'sagitario'      
        ELSE 'capricornio'
    END AS signo
FROM tabela a ;