🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.database
Article #835

Re: [���]һ��sql������ôд

#835
From: Galaxy��VOLUNTEERS��Database
Date: Wed, 19 Nov 2008 14:05
51 lines
2375 bytes
����sql server ��������û�����⡣
�������£�
�����?
CREATE TABLE [dbo].[TestTable_SQL](
    [Name] [nvarchar](50) NULL,
    [Price] [int] NULL,
    [date] [date] NULL,
    [time] [time](7) NULL
) ON [PRIMARY]

���뵽����ֵ���£�
Name    Price   date    time
a   1   2008-01-01  08:00:00.0000000
a   2   2008-01-01  08:30:00.0000000
a   3   2008-01-01  20:00:00.0000000
b   2   2008-01-01  12:00:00.0000000
a   4   2008-01-01  12:00:00.0000000
a   5   2008-01-02  08:00:00.0000000
b   2   2008-01-02  07:00:00.0000000

ʹ�ò�ѯ��
SELECT [Name]
      ,sum([Price]) as Price
      ,[date]
  FROM [TestDB1].[dbo].[TestTable_SQL]
  where [time]<'10:00'
  group by [date],[Name]
GO

���
Name    Price   date
a   3   2008-01-01
a   5   2008-01-02
b   2   2008-01-02

Ȼ����������з����ͺ���
�� �� WWF (WWF) �Ĵ������ᵽ: ��
: group by name,date֮��Ͳ����ˣ����ǰ���ÿ����ÿ�����ϲ��ۻ������ζ���һ�ٷ�
: �������� 
: ���õ���mysql
: �� �� pax (�����츮��ϲ���Ϻ�������) �Ĵ������ᵽ: ��
: :     ��д���Dz��Ҹ��˵ģ���name='xxx'�޶���
: :     �����ȫ���б?��ô��name='xxx'ȥ�� group������� name


--
Welcome to Database Board
��ӭ������ݿ��
http://bbs.sjtu.edu.cn/bbsdoc?board=database

�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 207.46.55.27]
Technical Details
Message-ID: <4d7akW$aSX@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!news.shec6.edu.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Thread: 101948,cd25524f7035ca48
X-Google-Attributes: gid101948,domainid0,public,usenet
X-Google-Language: ENGLISH,GB
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed.straub-nv.de!news.shec6.edu.cn!SJTU
From: Dem.bbs@bbs.sjtu.edu.cn (Galaxy��VOLUNTEERS��Database)
Newsgroups: cn.bbs.comp.database
Subject: Re: [���]һ��sql������ôд
Date: 19 Nov 2008 14:05:22 GMT
Organization: ��ˮ˼Դ
Message-ID: <4d7akW$aSX@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: database/M.1227103424.A