Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL] Select case when, grupowanie cen produktow w jednym zapytaniu
Agape
post
Post #1





Grupa: Zarejestrowani
Postów: 384
Pomógł: 13
Dołączył: 16.06.2006

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


Mam tabele z produktami gdzie jedna z kolumn jest `cena`, teraz musze pogrupowac produkty jednym zapytaniem zeby wiedziec ile jest w kazdym z podanych zakresow cenowych. Tworze wiec pytanie z case when:
  1. select count(`id`) as `ilosc`, case
  2. when `cena` < 1000 then '0 - 1000'
  3. when `cena` >= 2000 and `cena` < 3000 then "2000 - 3000"
  4. when `cena` >= 3000 and `cena` < 4000 then "3000 - 4000"
  5. as `range`
  6. from `produkty`


no i mam blad:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as `range` from `produkty`'. Nie moge dojsc czemu tam jest blad ...


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 20:26