Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Jednym zapytaniem - suma rekordów
yarot
post 20.02.2004, 18:40:24
Post #1





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 30.09.2003
Skąd: Wawa

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


Witam, potrzebuje wyciągnąć z bazy sumę rekordów gdzie stan = 1 i stan = 4 - jednym zapytaniem


[sql:1:529de26bd0]select count(idcoś) from tabela where stan = 1[/sql:1:529de26bd0]

[sql:1:529de26bd0]select count(idcoś) from tabela where stan = 4[/sql:1:529de26bd0]

Wiem że trzeba tabelę złączyć i zastosować distinct ale mam zaćmienie.
Go to the top of the page
+Quote Post
Jabol
post 20.02.2004, 19:03:02
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

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


[sql:1:a73659f781]select count(ilość) from tabela where pole in (1,4);[/sql:1:a73659f781]nie trzeba nic złączać i distinctować.
Go to the top of the page
+Quote Post
yarot
post 20.02.2004, 19:16:42
Post #3





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 30.09.2003
Skąd: Wawa

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


ok thx a wieksze od zera i różne od 3?
Go to the top of the page
+Quote Post
Jabol
post 20.02.2004, 19:20:53
Post #4





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

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


Cytat
ok  thx a wieksze od zera i różne od 3?
[sql:1:4633895486]select count(pole1) from tabela where xxx>0 and xxx not in (3,x,x,x,etc)[/sql:1:4633895486]Tutaj to już tylko proste łączenie warunków.[/sql]
Go to the top of the page
+Quote Post
yarot
post 20.02.2004, 19:24:32
Post #5





Grupa: Zarejestrowani
Postów: 29
Pomógł: 0
Dołączył: 30.09.2003
Skąd: Wawa

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


Dzięki ponownie ale zrobiłem inaczej

[sql:1:6debeeac77]select count(ilość) from tabela where pole = interval (1,2,4,5);[/sql:1:6debeeac77]
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: 24.07.2025 - 17:13