Re: SQL that performs division
- From: Bruce Lewis <brlspam@xxxxxxxxx>
- Date: 28 Feb 2007 09:30:05 -0500
"Chris" <Christopher.Lyth@xxxxxxxxx> writes:
This may not be the best place for this but here goes...
comp.databases would certainly be better. Sorry it's taking you so long
to get a good answer.
That is a list of some of the values, it is column measure_name and
conversion_rate, the conversion rate for these measures are all
exressed in teaspoons.
The SQL query I wrote to do the conversion is here:
-- how many cups in a hogshead?
SELECT b1/a1 conversion FROM
(SELECT m.conversion_rate a1 FROM measure m
WHERE m.measure_name = 'cup') a, (SELECT m1.conversion_rate b1 FROM
measure m1
WHERE m1.measure_name = 'hogshead') b;
SELECT hogshead.conversion_rate / cup.conversion_rate
FROM measure hogshead, measure cup
WHERE hogshead.measure_name = 'hogshead'
AND cup.measure_name = 'cup'
I'm using MySQL 5.0, im sure there are functions i can be using but
the join is what im worried about the most,
This to me is a very ugly SQL query and im thinking there's a better
way to do this, does anyone have any ideas on how i can improve this
query?
If you're using mysql, chances are you're looking at bad examples. If
postgresql is available you'd be better off using it.
--
http://ourdoings.com/ Easily organize and disseminate news and
photos for your family or group.
.
- References:
- SQL that performs division
- From: Chris
- SQL that performs division
- Prev by Date: Re: Some indexes not used in JDBC call
- Previous by thread: Re: SQL that performs division
- Next by thread: Aggregate function error with Access database
- Index(es):
Relevant Pages
|