🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: it.comp.lang.delphi
Article #7

Interrogazione SQL

#7
From: Daniele
Date: Tue, 01 Dec 2026 15:43
45 lines
2514 bytes
Cia a tutti,
   sono fuori argomento .... chiedo scusa.
Ho un problema con una interrogazione sql.
Il data base, di terze parti, e' strutturato con tabelle master, detail 
ed altre (legate alla detail).
Quello che devo estrarre e' su piu' tabelle ecco cosa devo fare.

Tabella 1 contiene la data
Tabella 2 contiene il lavorato
Tabella 3 contiene i dettagli dei prodotti
Tabella 4 contiene il riferimento della ditta produttrice

la query deve ritornare quanti giorni si sono lavorati in dato periodo 
solo se il venduto ha superato 200 euro, di questi giorni devo isolare 
solo le vendite fatte per una certa ditta produttrice.

Non so come fare e non ho trovato argomenti validi.
Non so come si possa far coesistere una sum con una distinct
La distinct serve per isolare i giorni lavorati la sum per sommare i 
campi "contanti" e "carta"

Per esempio

Select distinc DATA from tabella1 where tabella1.data between 
'2026-11-01' and '2026-11-30'

ottengo le date che hanno lavorato ... ma per gli altri dati ?
La query dovrebbe essere

Select distinc Tabella1.DATA, sum(Tabella2.contanti + Tabella2.carta) as 
somma
         inner join Tabella2 on tabella2.movimento = Tabella1.movimento
  from tabella1
       where tabella1.data between '2026-11-01' and '2026-11-30' and 
(somma >200)
       group by tabella2.contanti, tabella2.carta

Non va.

Qualche suggerimento ?

Grazie ...

Ciao
Daniele
Technical Details
Message-ID: <11empu8$1rg2f$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Daniele <daniele.xxxx@yyyyy.ww>
Newsgroups: it.comp.lang.delphi
Subject: Interrogazione SQL
Date: Tue, 1 Dec 2026 16:43:03 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <11empu8$1rg2f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 01 Dec 2026 15:43:05 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1949775"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/Dznr3b1U7HH90OOPkWjhBun0MpoTRYM0="; posting-host="4d873e325a7c2292fab981066d387931"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cShx0WzjCeY9b59Kuj7Tfrkw6hQ= sha256:KOssHQN11w1jcvFo+5sm5YW3oxLsMpKwkO0fHvgMS5o=
	sha1:VO5yQLv7FqwHVucd5/HtUbuRMVY= sha256:RI5mX+bfQ6abY+JlDKY1zE6QZR5cFligcTzyGn34Spg=
Content-Language: it