COMPARISON OF MES

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

Poston Tue, 12 Feb 2008 7:42 am

Hello GUYS IM HAVE a DOUBT of HOW to SET UP a SELECT.

HOW CAN I DO a SELECT to get a CUSTOMER'S FINANCIAL AS FOLLOWS: a SELECT to GET the difference of AMOUNT PAID BETWEEN ONE MONTH and ANOTHER KIND THIS MONTH the GUY PAID 50 I WANT to BRING IF IF THIS GUY LAST MONTH PAID ANYTHING OTHER THAN 50 SELECT no VALUE FROM NOTE N WHERE N. DTNOTA = ' 3/20/2007 ' AND EXISTS (SELECT a. VALUE FROM the NOTE WHERE the. DTNOTA = ' 2/20/2007 ' AND no VALUE <> A. VALUE) IS DOING SO OR IS THERE A BETTER WAY?
carlos12
Location: rio

Poston Tue, 12 Feb 2008 2:32 pm

would be more or less like this: select abs (n1. value-(select value from i2. Note n2 where dtnota = ' n2.3/20/2007 ' and rownum = 1)) from note n1 where n1. dtnota = ' 2/20/2007 ';

put the rownum = 1, because otherwise the error saying q the subquery can return more than one row, I think putting any group function and taking the rownum of right também ... Oh if you want q não appears the q are equal, doing a select on top of that and discards the rows that return zero ... see ya
rerodrig
Location: Americana - SP

Poston Tue, 12 Feb 2008 2:37 pm

Oh, one more thing, if this dtnota field is of type date must give the to_char for comparison with a string ... do not know if you put just to show the example but it's worth the warning! See ya!
rerodrig
Location: Americana - SP



Return to SQL

Who is online

Users browsing this forum: No registered users and 3 guests