Case for age

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Thu, 06 Dec 2007 9:57 am

To aqui again come on there SELECT DISTINCT U. field1, Field2, u.s. (u.s. birth, Sysdate), OLD Age (u. DTINICIO, Sysdate) Tempo_Ativo, doubts FROM table1 U, (select case when age (u.s. birth, Sysdate) < = 17 then 1 when age (u.s. birth, Sysdate) > = 18 then 2 when age (u.s. birth, Sysdate) > = 24 then 3 when age (u.s. birth, Sysdate) > = 29 then 4 when age (u.s. birth, Sysdate) > = 34 then 5 when age (u. birth, Sysdate) > = 39 then 6 when age (u.s. birth, Sysdate) > = 44 then 7 when age (u.s. birth, Sysdate) > = 49 then 8 when age (u.s. birth, Sysdate) > = 54 then 9 when age (u.s. birth, Sysdate) > = 59 then 10 end text WHERE u. = ' 00 ' Field1 and bla, bla, bla well folks I'm not able to make the select bring ages, why is :?: it gives error and is piscanco behind the \"WERE\" why?
carlos12
Location: rio

Poston Thu, 06 Dec 2007 10:07 am

And Carlos beauty??

Dude, you want to use the case as if it were a subquery?
you could post the select all here??

said!!

[] 's
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Thu, 06 Dec 2007 10:24 am

Brother beleza?

Man, as the Tineks would be better, falow put all the words here, but makes a test, I think you're missing a parenthesis after the word text:
Code: Select all
SELECT DISTINCT U.campo1, U.campo2, (U.nascimento, Sysdate) Idade,
IDADE(U.DTINICIO, Sysdate) Tempo_Ativo, duvida

FROM tabela1 U, (select
case
when idade(U.nascimento, Sysdate ) <= 17 then 1
when idade(U.nascimento, Sysdate) >= 18 then 2
when idade(U.nascimento, Sysdate) >= 24 then 3
when idade(U.nascimento, Sysdate) >= 29 then 4
when idade(U.nascimento, Sysdate) >= 34 then 5
when idade(U.nascimento, Sysdate) >= 39 then 6
when idade(U.nascimento, Sysdate) >= 44 then 7
when idade(U.nascimento, Sysdate) >= 49 then 8
when idade(U.nascimento, Sysdate) >= 54 then 9
when idade(U.nascimento, Sysdate) >= 59 then 10
end texto)
WHERE
u.campo1= '00' and
bla, bla, bla
the following is an example with subquery:
Code: Select all
SELECT *
  FROM (SELECT CASE
                  WHEN (TO_CHAR (SYSDATE, 'dd')) < 30
                     THEN 1
                  ELSE 2
               END
          FROM DUAL) teste
qualquer thing, says ai.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Thu, 06 Dec 2007 10:35 am

pow gave right I'm talking about you guys are beasts, but aqui about the tables you squeezed me now, rs is firm and the tables are about the sarbanes, one can take the risk, imagine someone sees ai suddenly Scrolls one passing pro (parana) (on the street) hehehe, ai ever seen right, I hope you understand a friend gets upset but when post aqui I always give a disguised in the fields.

but o the table okay identical gave certinho once again thank you
carlos12
Location: rio

Poston Thu, 06 Dec 2007 11:01 am

Beauty, brother, you're absolutely right.
Is that really has no way to help people, when you lack one or other information, or the message is specific to that model.

But, you are doing so without problems ...
When you can't, mascara, creates a table like other information and send to us.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP



Return to SQL

Who is online

Users browsing this forum: No registered users and 2 guests