Tema: Re: mssql - kaip i?rinkti vien? ?ra?? i? dviej?
Autorius: Jornada Del Muerto
Data: 2010-11-11 13:39:33
Man cia lauku truksta:
DeviceId
Data datetime
O tada:
SELECT
CONVERT(char(13), d.data, 25) as grp,
d.deviceId,
SUM(d.Val) AS suma
FROM
devices d
GROUP BY
CONVERT(char(13), d.data, 25),
d.deviceId
Jei reik dar ir state tai innerjoinink subquery ir dasidek pagal: CONVERT(char(13), d.data, 25) ir deviceId kitaip cia jovalas kazkoks strukturoje jei siu identifikatoriu ner....
Dariau pagal testine lenta:
CREATE TABLE [dbo].[devices](
[id] [int] IDENTITY(1,1) NOT NULL,
[deviceId] [int] NOT NULL CONSTRAINT [DF_devices_deviceId] DEFAULT ((0)),
[data] [datetime] NULL CONSTRAINT [DF_devices_data] DEFAULT (getdate()),
[Val] [int] NOT NULL CONSTRAINT [DF_devices_Val] DEFAULT ((0)),
[State] [bit] NOT NULL CONSTRAINT [DF_devices_State] DEFAULT ((0)),
[StateTime] [int] NOT NULL CONSTRAINT [DF_devices_StateTime] DEFAULT ((0)),
CONSTRAINT [PK_devices] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
"bala nemate" <bala.nemate@gmail.com> wrote in message news:ibg9ru$54v$1@trimpas.omnitel.net...
> as irgi negeriau, todel nematau elementaraus sprendimo panosej. minute
> pagalvojus, ir arkliui aisku, kad tavo variantas geras.
> kuom gerai su kitais pasitarti, kad is sono pasimato kiti keliai, apie
> kuriuos seniai negalvoji.
>
> dekui
> bn
>
>> Na, dar kavos negėriau, tačiau ar tokiai sąlygai tikrai netinka:
>> SELECT * FROM table WHERE State=1 OR StateTime=60
>
>