Solved

help needed with Microsoft SQL Server syntax

Posted on 2011-03-14
5
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Recursion schedule 13 48
Syntax error creating JSON recordset 4 43
Estimating my database size 7 51
Queries: Select, then Append, then Delete 8 41
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
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.​
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

751 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