Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Temporary columns - problem z warunkiem
ekstro
post 22.06.2009, 20:11:30
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 11.10.2008

Ostrzeżenie: (0%)
-----


Cześć, mam taki problem:

  1. SELECT t1.id, t1.op_name,
  2.  
  3. @invoice_sum_tax:=(SELECT sum((b1.price_base*b1.quantity)*(b3.rate+1)) FROM t24_invoices_elements AS b1 LEFT JOIN t24_taxes AS b3 ON b3.id = b1.code_taxes WHERE code_invoices = t1.id ) AS invoice_sum_tax,
  4.  
  5. @payments_sum:=(SELECT sum(c1.value) FROM t24_payments_list AS c1 WHERE c1.code_invoices = t1.id) AS payments_sum,
  6.  
  7. (@invoice_sum_tax-@payments_sum ) AS saldo
  8.  
  9. FROM (t24_invoices AS t1) LEFT JOIN t24_customers AS t2 ON t2.id=t1.code_customers


i teraz nie działa ani WHERE saldo > 0 ani HAVING > 0

Będę wdzięczny za pomoc w tej kwestii.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
dymsza
post 23.06.2009, 11:56:19
Post #2





Grupa: Zarejestrowani
Postów: 62
Pomógł: 4
Dołączył: 24.08.2006

Ostrzeżenie: (0%)
-----


  1. SELECT * FROM (SELECT t1.id, t1.op_name,
  2.  
  3. @invoice_sum_tax:=(SELECT sum((b1.price_base*b1.quantity)*(b3.rate+1)) FROM t24_invoices_elements AS b1 LEFT JOIN t24_taxes AS b3 ON b3.id = b1.code_taxes WHERE code_invoices = t1.id ) AS invoice_sum_tax,
  4.  
  5. @payments_sum:=(SELECT sum(c1.value) FROM t24_payments_list AS c1 WHERE c1.code_invoices = t1.id) AS payments_sum,
  6.  
  7. (@invoice_sum_tax-@payments_sum ) AS saldo
  8.  
  9. FROM (t24_invoices AS t1) LEFT JOIN t24_customers AS t2 ON t2.id=t1.code_customers ) AS t1 WHERE t1.saldo >0
Go to the top of the page
+Quote Post
ekstro
post 23.06.2009, 15:02:12
Post #3





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 11.10.2008

Ostrzeżenie: (0%)
-----


Dzięki!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.06.2025 - 12:24