sql >> Database teknologi >  >> RDS >> PostgreSQL

kolonnen eksisterer ikke fejl, selv når du bruger søgeordet 'som'

erstatte where errors >= 1 med (cast(a.count as decimal) * 100 / b.count)>=1 da der ikke er nogen kolonne kaldet fejl, men en afledt kolonne :

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

Det kan bruges som ovenfor som nedenfor :

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 underforespørgsel.



  1. org.hibernate.AssertionFailure:null id i indtastning (du skal ikke tømme sessionen efter en undtagelse)

  2. Brug af flere felter til en unik nøgle i Prisma

  3. DataGridView viser ikke mine kolonner

  4. Er der en måde at bruge DBMS_Alert til at underrette en Winform-applikation om en databaseændring