bir formül içinde çalışmak için dava alma: Eğer ben de fark ben o sorgunun kapalı çalışacak başka bir sütun olmasını istedik sonraçalışır ben sql özel bir sütun var
,case
when(extract(day from now() - 2)) < 3
then '1'
else extract(day from now() - 2)
end as MTD
ve ancak verebilirdim zaman formülde aynı şekilde
ı olurdu sonraki olmasını istedik orijinal sorgu çalışacak düşünerek davayı almaya çalıştı vb adlandırarak/kaydetmeden bu konuda oldukça sorgusu:
,(combo.autotradercom_vdp + combo.carscom_vdp)/min(MTD, combo.age) as VDP/MTD
Bir HATA alıyorum
,(combo.autotradercom_vdp + combo.carscom_vdp)/min(case when (extract(day from now() - 2)) < 3 then '1' else extract (day from now() - 2) end, combo.age) as VDP/MTD
:
yüzden bunun yerine benim mantığı ile çalışır ancak gereken bu değil inşa ya da yakınında "#" sözdizimi hatası ve ben sorun min olduğunu biliyoruz() Sorgunun bir parçası, ancak sorunun nerede olduğunu anlayamıyorum.
Herhangi bir yardım için teşekkür ederiz!
Düzenleme:
eklendi bütün sorgu
--work in brogress, will automate inventory review excel doc
select
case
when combo.total_repairs < 1
then 'None'
when combo.total_repairs < (combo.guaranteed_price * 4)/100
then 'Lo'
when combo.total_repairs between(combo.guaranteed_price * 4)/100
and (
combo.guaranteed_price * 8
)
/100
then 'Med'
else 'Hi'
end as Repair_Tier
, case
when combo.list_price < combo.guaranteed_price
then '0'
else combo.seller_upside_percentage
end as Seller_Upside
, combo.days_to_expiration as Days_remaining_on_contract
, case
when(combo.deposit + combo.needs_repairs + combo.going_to_auction + combo.in_transit + combo.hold_for_trade_in + combo.hold_for_financing) > 0
or left(combo.paperwork_missing, 3) = 'Yes'
then concat('Reserved - ', case when combo.deposit > 0 then 'Deposit' when combo.needs_repairs > 0 then 'Needs Repairs' when combo.going_to_auction > 0 then 'Going to Auction' when combo.in_transit > 0 then 'In Transit' when combo.hold_for_trade_in > 0 then 'Hold for Trade-In' when combo.hold_for_financing > 0 then 'Hold for Financing' else concat('Paperwork Missing - ', combo.paperwork_missing_reason) end)
else ''
end as Reserved
, case
when combo.future_test_drives > 0
then combo.future_test_drives
else '0'
end as Future_Test_Drives
, case
when combo.recent_test_drives > 0
then combo.recent_test_drives
else '0'
end as Recent_Test_Drivescase
, case
when combo.recent_buyer_leads > 0
then combo.recent_buyer_leads
else '0'
end as Recent_Buyer_Leads
--MTD-2
, case
when(extract(day from now() - 2)) < 3
then 1
else extract(day from now() - 2)
end as MTD
, (combo.autotradercom_vdp + combo.carscom_vdp)/min (case
when(extract(day from now() - 2)) < 3
then '1'
else extract(day from now() - 2)
end, combo.age) as VDP/MTD
from
[combo]
sorgunuzla gösterin. – Siyual
(1) Soruyu kullandığınız veritabanı ile etiketleyin; (2) bir sütun takma bir 'select' olarak kullanılamaz (ya da' where' veya grup bir by' vs.) tanımlandığı 'select' karşılık gelir. –
Takip edilen ve güncellenen – wezzeh