🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.databases.mssql-l
Article #10

SQL Query - please help!!!

#10
From: ComputerMan
Date: Sat, 14 Feb 2004 22:46
9 lines
1643 bytes
I am looking for a SQL command that allows me to list for example the top 2
or 3 values for each category. for example I have a table with names, town,
salary. I want the names of the two people who have the highest salaries in
each town.  Imagine the towns are Liverpool, Southport, London. the result
of query should give me two names for each town and the names, towns and
salaries must be listed.  The listed names must be those who get the highest
salaries in each town. Looked in every book but not found it. I found a Top
command but didn't give me the correct results. Hope someone can help.
Thanks
Technical Details
Message-ID: <c0m8fq$jks$1@hercules.btinternet.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nx02.iad01.newshosting.com!newshosting.com!news-peer0-test!btnet-feed5!btnet!news.btopenworld.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6611,ddad40cdb9245699,start
X-Google-Attributes: gidf6611,public
X-Google-ArrivalTime: 2004-02-14 14:47:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nx02.iad01.newshosting.com!newshosting.com!news-peer0-test!btnet-feed5!btnet!news.btopenworld.com!not-for-mail
From: "ComputerMan" <talktome@btinternet.com>
Newsgroups: bit.databases.mssql-l
Subject: SQL Query - please help!!!
Date: Sat, 14 Feb 2004 22:46:18 +0000 (UTC)
Organization: BT Openworld
Lines: 12
Message-ID: <c0m8fq$jks$1@hercules.btinternet.com>
NNTP-Posting-Host: dial81-131-54-55.in-addr.btopenworld.com
X-Trace: hercules.btinternet.com 1076798778 20124 81.131.54.55 (14 Feb 2004 22:46:18 GMT)
X-Complaints-To: news-complaints@lists.btinternet.com
NNTP-Posting-Date: Sat, 14 Feb 2004 22:46:18 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000