>num_persone = 5
>data_arrivo= 09/03/2008
>data_partenza = 11/03/2008
>
>come presenze devo uscire il seguente numero: 5 x 3(giorni) =
>15
3gg? 11-9 fa 2
USE tempdb;
CREATE TABLE dbo.Tabella(
num_persone int NOT NULL,
data_arrivo smalldatetime NOT NULL,
data_partenza smalldatetime NOT NULL
);
INSERT dbo.Tabella VALUES(5, '20080309', '20080311');
INSERT dbo.Tabella VALUES(4, '20080310', '20080317');
SELECT num_persone * DATEDIFF(day, data_arrivo, data_partenza) AS Tot
FROM dbo.Tabella;
/* Output:
Tot
-----------
10
28
(2 row(s) affected)
*/
DROP TABLE dbo.Tabella;
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
http://italy.mvps.org