Solved

help needed with Microsoft SQL Server syntax

Posted on 2011-03-14
5
194 Views
Last Modified: 2012-05-11

select 10 records from customers table for each city then inner join the customerid = customerid of all the tables that have those customerid and therefore returning the city, customerid, tablename and orderdate
0
Comment
Question by:Jimmy_inc
  • 3
5 Comments
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 35135458
0
 
LVL 19

Accepted Solution

by:
Bhavesh Shah earned 250 total points
ID: 35135459
Hi,


SELECT * FROM
(
SELECT Country, CustomerName, ROW_NUMBER() OVER(PARTITION BY Country ORDER BY Country DESC) AS 'Row'
from table1
)
WHERE Row <= 5



Just join table with above query
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
ID: 35135463
try this


 select customerid , City from Customers
where (
   select count(*) from Customers as f
   where f.City  = Customers.City
) <= 5
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 35135464
Hi Jimmy,

sorry...But you posted 3 Questions and all are interlinked so its advisable that post one question with all queries.

Thanks

Bhavesh
0
 

Author Comment

by:Jimmy_inc
ID: 35135508
Hi Brichsoft

Yeah your'e right -  Not enough coffee !

I should of only posted this question:

http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_26887029.html

Which others are interlinked too ?
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question