March 10, 2014 at 12:41 pm
Hi all, Please see example for more details
I got 3 different tables and my query is
Select Productaname, Sum(sales), Region from t1 inner join t2 inner join 3
group by productname, region
I'm getting results
Country1
Sales
Pdname
x 10
y 10
But i want to display results like below and i want only top 3 records by sales..
Country1 Country2 Country3
Sales Sales Sales
Pdname
x 10 20 30
y 10 20 30
z 10 20 30
I hope this helps ..thanks
March 10, 2014 at 12:47 pm
Take a look at the pivot command and see if that helps.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 10, 2014 at 12:54 pm
Thanks for your reply
Well, I have used matrix to display results..but i can't get desired result..thanks
March 10, 2014 at 1:09 pm
If you have the country in the results you are looking at, then you drop the country into the columns section of the matrix.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 10, 2014 at 2:22 pm
Thank you 4r reply..I got the answer now..I have did same thing before but i have used top in my query..
the reason for using top query is i want to display top 4 sales amount by prodcutname,country..If i use top in my query it will only giving top 4 out of all countries names..But i want sales top 4 for each country thanks..Please find attached image for more details..thanks
March 10, 2014 at 5:41 pm
nandu.chowdary412 (3/10/2014)
Thank you 4r reply..I got the answer now..I have did same thing before but i have used top in my query..the reason for using top query is i want to display top 4 sales amount by prodcutname,country..If i use top in my query it will only giving top 4 out of all countries names..But i want sales top 4 for each country thanks..Please find attached image for more details..thanks
Images of data are pretty unfriendly. If you want some coded help, please see the first link in my signature line below under "Helpful Links" for how to post data for your question.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply