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 |
|
webstep
Starting Member
3 Posts |
Posted - 2003-07-09 : 20:30:09
|
| Selecting one row from a tableHi all I have a table that has some rows like the example 1The: represent the filed in the tableI wish to write a sql query that it produces one row for the result when querying colum G so output looks like example 2 Example 1 A : B : C : D : E :F : GThe : cat : jumped : over :the : mat : 1 The : cat : jumped : over :the : mat : 1 The : cat : jumped : over :the : mat : 1 The : cat : jumped : over :the : mat : 1 The : cat : jumped : over :the : mat : 2The : cat : jumped : over :the : mat : 2The : cat : jumped : over :the : mat : 2Example 2The cat jumped over the mat 1The cat jumped over the mat 2O/S windows 2000 / SQL M/S SQL2000 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-07-09 : 20:34:05
|
| For one thing, why do you have duplicate rows? You can certainly remove them in a query:SELECT DISTINCT A, B, C, D, E, F, G FROM myTable...but if your table was designed properly it would have constraints on it to prevent such duplicates from being inserted into the table in the first place. |
 |
|
|
webstep
Starting Member
3 Posts |
Posted - 2003-07-10 : 00:26:53
|
| Actuality the fields are a bit different and I am creating a database for some music recordsIf you could shed some light on what I should be doing to make things a bit easier that would be appreciatedI have a data base structure like this -----------------Tracks-----------------Artist TextTitle TextTrack_No NumericVol_Name TextVol_Ref_No TextPrice MoneyEdited by - webstep on 07/10/2003 00:27:48 |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-07-10 : 03:31:06
|
| You need some criteria that determins which of the fields ABCDEF get shown for each different G.Either of SELECT DISTINCT or a group by should help you in what you want to do.-------Moo. :) |
 |
|
|
|
|
|