sql >> Databasteknik >  >> RDS >> PostgreSQL

kolumnen finns inte fel även när du använder nyckelordet "som".

ersätt where errors >= 1 med (cast(a.count as decimal) * 100 / b.count)>=1 eftersom det inte finns någon kolumn som heter fel utan en härledd kolumn :

select a.date, (cast(a.count as decimal) * 100 / b.count) as errors
  from (select date(time) as date, count(status)
          from log
         where status != '200 OK'
         group by date
         order by date asc) as a
  join (select date(time) as date, count(status)
          from log
         group by date
         order by date asc) as b
    on a.date = b.date
 where (cast(a.count as decimal) * 100 / b.count) >= 1
 order by errors desc; 

ELLER

Den kan användas enligt ovan enligt nedan :

select *
  from (select a.date, (cast(a.count as decimal) * 100 / b.count) as errors
          from (select date(time) as date, count(status)
                  from log
                 where status != '200 OK'
                 group by date
                 order by date asc) as a
          join (select date(time) as date, count(status)
                 from log
                group by date
                order by date asc) as b
            on a.date = b.date) q
 where errors >= 1
 order by errors desc;

i en underfråga.



  1. Hur kan jag avinstallera oracle 11g helt?

  2. Dela upp enorma (95 Mb) JSON-arrayer i mindre bitar?

  3. Lagra bilder i SQL Server?

  4. PHP-fråga:PDO Prepare() och Execute() med MYSQL IN() fungerar inte för arrayer