数据库sql编写程序求解百鸡百钱问题。公鸡 5 元一只,母鸡 3 元一只,小鸡一元 3 只, 问 100 元钱买 100 只鸡,可买公鸡、母鸡、小鸡各多少只?
时间: 2024-06-01 07:10:51 浏览: 58
MySQL数据库开发与SQL编写规范详解
SELECT
x AS "公鸡数量",
y AS "母鸡数量",
z AS "小鸡数量"
FROM
(SELECT
a.n AS x,
b.n AS y,
(100 - 5*a.n - 3*b.n)*3 AS z
FROM
(SELECT
rownum AS n
FROM
all_objects
WHERE
rownum <= 20) a
CROSS JOIN
(SELECT
rownum AS n
FROM
all_objects
WHERE
rownum <= 33) b
WHERE
5*a.n + 3*b.n + (100 - 5*a.n - 3*b.n)*3/3 = 100)
WHERE
z <= 100;
阅读全文