Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

find maxsales details in sql server Expand / Collapse
Author
Message
Posted Friday, June 28, 2013 12:05 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 10:21 AM
Points: 197, Visits: 4,400
hi friends i have small doubt in sql server plese tell me how to solve this issuse

table data contains like




pid pdate price
1 2013-02-10 100
1 2013-03-11 100
1 2013-04-14 100
2 2013-04-10 100
2 2013-08-04 100
3 2013-05-24 100
1 2013-07-05 100
2 2013-04-05 500
2 2013-04-01 200
2 2013-06-02 200


based on this i want display max prodcut id sales details



actualy i tryied like this way


select pid,COUNT(pid)as b from product group by pid having max(pid)=1


but its not give exactely result.plz tell me query how to solve this isuse in sql server.
Post #1468438
Posted Friday, June 28, 2013 12:43 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, April 17, 2014 10:56 PM
Points: 1,111, Visits: 535
Can u provide the sample output which u need?
Post #1468441
Posted Friday, June 28, 2013 4:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 23, 2013 5:58 AM
Points: 4, Visits: 32
Can you please explain little more what kind of output you want?
its not clear.
Post #1468492
Posted Friday, June 28, 2013 7:55 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 11,990, Visits: 11,007
In order to help we will need a few things:

1. Sample DDL in the form of CREATE TABLE statements
2. Sample data in the form of INSERT INTO statements
3. Expected results based on the sample data

I posted a nice example of how to post this stuff in your other thread. This is a great opportunity for you to do it this time.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1468555
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse