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 |
|
irehman
Starting Member
22 Posts |
Posted - 2002-01-15 : 22:44:55
|
| I have the following Data in one table.LotNum Desc Tally_DT Tally_Site QtyRecv101 Electronic 01/05/02 J 10101 Electronic 01/06/02 J 20*101 Electronic 01/07/02 J 30102 Bottles 01/04/02 J 10*102 Bottles 01/04/02 J 20*103 Cups 01/02/02 J 50I need to write a query that would give me records with anasterick(*) sign. Because the records contains the mostrecent date. Also, I need to group it by LotNum.I can pull out Tally_DT and Lot_Num but as soon as IAdd more columns in select statement, it gives all the records for each lotNum. Thanks in AdvanceEdited by - irehman on 01/15/2002 22:45:24Edited by - irehman on 01/15/2002 22:46:28Edited by - irehman on 01/15/2002 22:46:53Edited by - irehman on 01/15/2002 22:47:40 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-01-15 : 23:24:47
|
| HiThat is a really poor database design. You should have lotnum as an integer. Then have the flag in another column.Your question is also a little vague. Yes, if you add more columns, and they are different, it will affect your grouping. What result are you trying to get ?Damian |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-15 : 23:33:46
|
| select distinct t1.* from tablename t1inner join(select lot_num,max(Tally_DT) MDT from tablename) t2on t1.lot_num=t2.lot_num and t1.Tally_Dt=t2.MDTHTH----------------------------------"True love stories don't have endings."Edited by - Nazim on 01/15/2002 23:35:05 |
 |
|
|
|
|
|