SQL Query Beyanında Bölümü

0 Cevap php

Ben çift hassasiyetli değerleri tek bir sütun döndüren iki sorgu var:

(SELECT scale 
   FROM (SELECT title, 
                scale,
                dense_rank() OVER (PARTITION BY title 
                                       ORDER BY scale ASC) AS r 
           FROM signatures) t
  WHERE r = 1)

... Ve:

(SELECT scale 
   FROM (SELECT scale,
                dense_rank() OVER (PARTITION BY title 
                                       ORDER BY scale ASC) AS r 
           FROM signatures) t
  WHERE r = 2) 

Ben ikinci sorgu (Q2) bölünmesiyle ilk sorguyu (Q1) SEÇ çalışıyorum. Yani, (Q1 itibaren ROW1) / (Q2 den ROW1). Ve satır kalanını aşağı devam etti.

Ben denedim:

SELECT ((SELECT scale 
           FROM (SELECT title, 
                        scale,
                        dense_rank() OVER (PARTITION BY title  
                                               ORDER BY scale ASC) AS r 
                   FROM signatures) t
          WHERE r = 1)

/

(SELECT scale 
   FROM (SELECT scale,
                dense_rank() OVER (PARTITION BY title 
                                       ORDER BY scale ASC) AS r 
           FROM signatures) t
  WHERE r = 2) 
)

But have had no luck. Can anyone see a way to do this? I can send the two queries separately, then run through a loop and divide the elements, but that won't work for a semi-large recordset.

Ayrıca, bu önemli değil, ama ben PostgreSQL kullanıyorum.

0 Cevap