Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

help needed with Microsoft SQL Server syntax

Posted on 2011-03-14
5
Medium Priority
?
200 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 1000 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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