Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-09-05 : 08:36:39
|
| FEDERICO writes "I' m using this line:"SELECT * FROM base v1 WHERE v1.date = (SELECT MAX(v2.date) FROM base v2 WHERE v1.codpiece = v2.codpiece AND v1.colpiece = v2.colpiece)"I want to select the last dates of every piece in the base. Cod piece sometimes is a text record, and it can start with numbers and have spaces between or end with soaces to fill 15 characters.The problem is that is working bad when the day or the month stored in "date" is between 01 and 09.I'm using VB 5.0 with a DBGrid.Please tell me what to do!!Thanks." |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-09-05 : 12:31:23
|
| show us sample data....it's easier that trying to understand descriptive text. |
 |
|
|
dsdeming
479 Posts |
Posted - 2002-09-06 : 08:10:36
|
| What is the datatype of your date column? The fact that you're specifically having trouble with your MAX( date ) where the month is less than 10 leads me to believe the column contains character data. If so, you'll have to run CAST or CONVERT against the column to convert the data to datetime before the MAX function will return meaningful results. |
 |
|
|
|
|
|