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 |
|
omega1983
Starting Member
40 Posts |
Posted - 2009-09-17 : 20:20:26
|
| have the following code. THe first creates a table called Make_Batches. The second is an attempt to find duplicate batches if the batch number repeats itself. THe problem is since I chose the count of the giftid in the first table, it is not a true field so the dupicate code will not accept. When I run the second query I get the error message, invalid column name giftId. WHy am I getting that message and what is the solution------------/*Table name is Make_Batches*/SELECT COUNT(giftid) AS CountOfID,giftbatch,giftclass1,gifteffdat,gifttype FROM gifts WHERE (gifttype = 'y' OR gifttype = 'g' OR gifttype = 'b') AND (gifteffdat >= '2008-01-01 00:00:00')--and giftbatch = '2530'GROUP BY giftbatch,giftclass1, gifteffdat, gifttype-------------------- Find duplicate batchesSELECT * FROM Make_Batches inner join batch_numberon giftbatch = table_val --As Tmp GROUP BY giftbatch,giftidHAVING Count(*)>1 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-17 : 21:43:39
|
[code]SELECT giftbatch,giftidFROM Make_Batches inner join batch_number on giftbatch = table_valGROUP BY giftbatch,giftidHAVING Count(*) > 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|