我有脚本查询选择这样。我想从查询选择中搜索max max和min'jumlah'。
SELECT
"B"."company" AS "B__company",
"User"."company" AS "User__company",
"Transaction"."create_date" AS "Transaction__create_date",
extract(day from "Transaction"."create_date"),
sum(cast("PLNPostpaid"."jumlahrek" as integer)) as jumlah,
sum("Transaction"."price_buy") as jumbuy,
sum(("Transaction"."price_sell")-("Transaction"."price_buy")) as admin
FROM "public"."transactions" AS "Transaction"
LEFT OUTER JOIN "public"."users" AS "User" ON ("User"."id" = "Transaction"."user_id")
FULL OUTER JOIN "public"."users" AS "B" ON ("B"."id" = "User"."bank")
LEFT JOIN "public"."inboxes" AS "Inbox" ON ("Inbox"."id" = "Transaction"."inbox_id")
LEFT JOIN "public"."pln_postpaids" AS "PLNPostpaid" ON ("Inbox"."id" = "PLNPostpaid"."inbox_id")
WHERE "Transaction"."create_date" >= '01-May-2015 00:00:00' AND "Transaction"."create_date" <= '31-May-2015 23:59:59'
AND "Transaction"."product_id"=100
GROUP BY extract(day from "Transaction"."create_date"), "Transaction"."create_date", "B"."company", "User"."company"
我想实现到php。任何人都可以帮助我吗?
答案 0 :(得分:0)
WITH all_data AS( - 你的初始请求在这里 ) 选择MIN(jumlah)为min_jumlah,MAX(jumlah)为max_jumlah 来自all_data