Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!csus.edu!ucdavis!csusac!unify!nico From: nico@Unify.Com (Nico Nierenberg) Newsgroups: comp.databases Subject: Re: Reports from SQL databases Keywords: SQL reports Message-ID: Date: 2 Apr 91 22:12:46 GMT References: <5197@mrmarx.UUCP> <49526@seismo.CSS.GOV> Organization: Unify Corporation, Sacramento, CA, USA Lines: 58 In article <49526@seismo.CSS.GOV> cooper@beno.CSS.GOV (Dale Cooper) writes: >In article nico@Unify.Com (Nico Nierenberg) writes: >>In article <5197@mrmarx.UUCP> cant@mrmarx.msc.com (Jim Cant) writes: >>>I have several questions and would appreciate any help I can get from >>>people on the net. >>> > >[stuff deleted] > >>>Here is a general question. I need to print reports with fields such >>>as sex and would like the printed output to say "male" or "female". The >>>database contains 1 and 0 for these values. How can I test each >>>record returned by a select statement for the value of sex and write >>>out "male" or "female" as appropriate. One solution that occurs is to >>--------------------------------------------------------------------- >>Nico Nierenberg >>Unify Corp. there you are." >>nico@unify > >Temporary tables are often VERY useful (absolutely no flame intended to you >Nico), but more times than not there is more than one way to skin a cat I agree that temporary tables are useful, but not in this case. The only thing I don't like about the Oracle example is that it is specific to Oracle. I might have said that using front end tools there are any number of ways to do it. Another interesting join example is the non equi-join. In this case you can solve problems like computing tax liability from an income value.. Imagine a tax table like; minincome |maxincome |basetax |rate ---------------------------------------------------------- 0 |12000 |0 |.15 12001 |30000 |1800 |.20 30001 |9999999999999 |5400 |.33 Then if you have an employee table with names and salary, you can compute (a very nominal tax) by; select name,salary, basetax + (salary - basetax) * rate from employee,tax where salary between minincome and maxincome; > >Dale Cooper, DBA D - dumped on >Center for Seismic Studies B - by >Arlington, VA A - all -- --------------------------------------------------------------------- Nicolas Nierenberg "No matter where you go, Unify Corp. there you are." nico@unify