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 |
|
gnaus
Starting Member
41 Posts |
Posted - 2011-09-21 : 05:54:46
|
| dear reader,I want to know from field "OpmerkingenIndicatie" at which record it has the most characters or the most Kb.My formula works so far, but I want that he shows me at which Clientcode (=field) this occurs. I don't know how to do this.this is my formula:SELECT ' OpmerkingenIndicatie,' (SELECT MAX(DATALENGTH(OpmerkingenIndicatie)) FROM dbo.Oefenomgeving$OpmerkingenIndicatie2) or SELECT ' OpmerkingenIndicatie,' ' Clientcode ' (SELECT MAX(DATALENGTH(OpmerkingenIndicatie)) FROM dbo.Oefenomgeving$OpmerkingenIndicatie2) but in both cases he tells me wich field is the biggest but he doesn't tell me at which clientcode that is.thank you,GN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-21 : 05:57:01
|
| [code]SELECT OpmerkingenIndicatie,ClientcodeFROM TableWHERE DATALENGTH(OpmerkingenIndicatie)=(SELECT MAX(DATALENGTH(OpmerkingenIndicatie) FROM table)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
gnaus
Starting Member
41 Posts |
Posted - 2011-09-22 : 04:03:09
|
| thank you! result: SELECT OpmerkingenIndicatie,ClientcodeFROM dbo.Oefenomgeving$OpmerkingenIndicatie2WHERE DATALENGTH(OpmerkingenIndicatie)=(SELECT MAX(DATALENGTH(OpmerkingenIndicatie) FROM dbo.Oefenomgeving$OpmerkingenIndicatie2)Foutmelding: Msg 156, Level 15, State 1, Line 13Incorrect syntax near the keyword 'FROM'.next try-out: SELECT OpmerkingenIndicatie,ClientcodeFROM dbo.Oefenomgeving$OpmerkingenIndicatie2WHERE DATALENGTH(OpmerkingenIndicatie)= MAX(DATALENGTH(OpmerkingenIndicatie))Msg 147, Level 15, State 1, Line 10An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.greetings, GNGN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-22 : 04:08:34
|
| [code]SELECT OpmerkingenIndicatie,ClientcodeFROM dbo.Oefenomgeving$OpmerkingenIndicatie2WHERE DATALENGTH(OpmerkingenIndicatie)=(SELECT MAX(DATALENGTH(OpmerkingenIndicatie)) FROM dbo.Oefenomgeving$OpmerkingenIndicatie2)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
gnaus
Starting Member
41 Posts |
Posted - 2011-09-22 : 05:15:43
|
| super! it works! thanks!! :)GN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-22 : 11:43:06
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|