Click here to Skip to main content
15,892,161 members
Home / Discussions / Database
   

Database

 
GeneralRe: design a database Pin
Jörgen Andersson20-Feb-12 3:34
professionalJörgen Andersson20-Feb-12 3:34 
AnswerRe: design a database Pin
smcnulty20005-Mar-12 22:03
smcnulty20005-Mar-12 22:03 
QuestionFinding the Max value per group. Pin
Clark Kent12317-Feb-12 5:47
professionalClark Kent12317-Feb-12 5:47 
AnswerRe: Finding the Max value per group. Pin
scottgp17-Feb-12 8:19
professionalscottgp17-Feb-12 8:19 
GeneralRe: Finding the Max value per group. Pin
Corporal Agarn17-Feb-12 8:36
professionalCorporal Agarn17-Feb-12 8:36 
GeneralRe: Finding the Max value per group. Pin
Clark Kent12321-Feb-12 2:58
professionalClark Kent12321-Feb-12 2:58 
AnswerRe: Finding the Max value per group. Pin
Eddy Vluggen17-Feb-12 8:47
professionalEddy Vluggen17-Feb-12 8:47 
QuestionRe: Finding the Max value per group. Pin
Clark Kent12321-Feb-12 2:55
professionalClark Kent12321-Feb-12 2:55 
Quote:
Can you extend the sample population to give some more detail?
Yes, I sure can!

What I need to do is organize a table that has multiple listings of a Project ID and return only 1 of the latest (date related) per Project ID. Therefore, here is a sample listing of the data that I need to organize.

ProjectID   ReportYear  ReportMonth
----------- ----------- -----------
100005000   2008	5
100005000   2008	6
100005000   2008	7
100006600   2008	8
100006600   2008	9
100006600   2008	10
100006600   2008	11
100006600   2008	12
100006600   2009	1
100006800   2008	8
100006800   2008	9
100006800   2009	1
100006800   2009	2
100006800   2009	3
100006800   2009	4

Note: I trimmed down the data so as not to overwhelm this post, but still relay the idea of what I am dealing with.

There is also one more thing I would like to ask your advice. It's about an idea that I have been thinking about. What if I were to instead create a temporary table and create an extra column with "ReportDate" and add the Year and Month together. (I know someone has also mentioned this in a reply to my first post). So, it would be something to the affect of (ReportYear * 100) + ReportMonth. Then I could write a query with the above sample data and return back per ProjectID the latests info. What do you think? Further, can you please link me to a "How-To" article on creating temp tables in SQL Server 2008?

One last question about something that I don't understand and have been searching MSDN and Google to no avail. It's this whole alias thing ("AS" keyword). You can place use this in for the column name and/or the table name. But I don't understand how I can do something to affect of ...
SELECT MAX(ReportYear) FROM vPSR AS f WHERE f.ProjectID = vPSR.ProjectID

I don't understand how f.ProjectID can equal vPSR.ProjectID. This seems very circular to me. This is a technique that I don't use often. If you have any info/advice about this way of writing a query can you link me?

Thanks!
AnswerRe: Finding the Max value per group. Pin
Eddy Vluggen21-Feb-12 7:35
professionalEddy Vluggen21-Feb-12 7:35 
GeneralRe: Finding the Max value per group. Pin
Clark Kent12322-Feb-12 2:21
professionalClark Kent12322-Feb-12 2:21 
GeneralRe: Finding the Max value per group. Pin
Eddy Vluggen23-Feb-12 0:05
professionalEddy Vluggen23-Feb-12 0:05 
QuestionSSRS 2005 verses OUTLOOK 2007 Pin
SQL Ed17-Feb-12 1:00
SQL Ed17-Feb-12 1:00 
AnswerRe: SSRS 2005 verses OUTLOOK 2007 Pin
cjb1105-Apr-12 1:24
cjb1105-Apr-12 1:24 
Questionoracle 11g alias to query Pin
hadad14-Feb-12 22:28
hadad14-Feb-12 22:28 
AnswerRe: oracle 11g alias to query Pin
Jörgen Andersson15-Feb-12 1:37
professionalJörgen Andersson15-Feb-12 1:37 
AnswerRe: oracle 11g alias to query Pin
Chris Meech15-Feb-12 3:00
Chris Meech15-Feb-12 3:00 
AnswerRe: oracle 11g alias to query PinPopular
David Skelly15-Feb-12 6:24
David Skelly15-Feb-12 6:24 
JokeRe: oracle 11g alias to query Pin
Bernhard Hiller15-Feb-12 21:04
Bernhard Hiller15-Feb-12 21:04 
GeneralRe: oracle 11g alias to query Pin
David Skelly15-Feb-12 22:05
David Skelly15-Feb-12 22:05 
Questionconcept of database Pin
messages13-Feb-12 22:56
messages13-Feb-12 22:56 
AnswerRe: concept of database Pin
Simon_Whale14-Feb-12 0:16
Simon_Whale14-Feb-12 0:16 
AnswerRe: concept of database Pin
uspatel17-Feb-12 23:54
professionaluspatel17-Feb-12 23:54 
NewsRe: concept of database Pin
Eddy Vluggen18-Feb-12 2:52
professionalEddy Vluggen18-Feb-12 2:52 
GeneralRe: concept of database Pin
messages19-Feb-12 5:09
messages19-Feb-12 5:09 
Questionhow do i design a database system for an app? Pin
BupeChombaDerrick13-Feb-12 13:06
BupeChombaDerrick13-Feb-12 13:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.