🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ������sql�

#64
From: Galaxy��VOLUNTEERS��Database
Date: Thu, 06 Aug 2009 08:43
41 lines
2316 bytes
create table #temp
drop #temp
����Ҳ���а�������
��ô���ö���ѯ��
������һ�£��ѵ�һ������������Щ���Ƶ�link��
How to display 0 in conditional [group by] report in Count() SQL Query 
http://lichao.net/eblog/how-to-display-0-in-conditional-group-by-report-in-co
unt-sql-query-200808164.html

�����и�query�����������Ҹղ�˵����left join�����⻹��nvl��
SELECT Region.Region_Name, NVL(SubTotal.Total,0) As SalesTotal
From Region
Left Join 
(SELECT Region, Count(Sales.Amount) As Total
From Sales
Where Amount > 1000
Group By Region) SubTotal
On Region.Region_id = SubTotal.Region

������£�
Region_Name SalesTotal 
East 1 
West 1 
North 1 
South 0 

�� �� zylover (zy) �Ĵ������ᵽ: ��
: ��Ҫ��������ϣ������ܽ���ʱ���
: �� �� Dem �Ĵ������ᵽ: ��
: : �ҵ��������ǽ������������İ�������
: : [[Post:database,M.1249543291.A|Re: ������sql�]]
: : �Ȱѷ����ø���ʱ��̶��ã�Ȼ����left joinƥ��group by����ݽ��
: : �����Ҳ�ȷ��Oracle���Ƿ�Ҳ�ܻ����SQL Server��ͬ�Ľ����


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

�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 207.46.55.28]
Technical Details
Message-ID: <4hIYFg$bSl@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news.shec6.edu.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Thread: 4df683fd51,adb32091b8365bec,start
X-Google-Attributes: gid4df683fd51,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.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: 06 Aug 2009 08:43:32 GMT
Organization: ��ˮ˼Դ
Message-ID: <4hIYFg$bSl@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: database/M.1249547514.A