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 |
Dev@nlkss
134 Posts |
Posted - 2009-04-24 : 05:48:21
|
I have following dataS 3 S 3 S 3 S 3 S 3 B 2 C 2 C 2 C 2 M 1 M 1 M 1 A 4 A 4 A 4 how do i display as followsS 3C 2M 1A 4$atya.Love All Serve All. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 05:53:48
|
SELECT DISTINCT Co1, Col2FROM Table1 E 12°55'05.63"N 56°04'39.26" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 05:54:20
|
B 2 is missing from your expected output? E 12°55'05.63"N 56°04'39.26" |
 |
|
Dev@nlkss
134 Posts |
Posted - 2009-04-24 : 06:13:41
|
Thanks for reply The actual data is as followsS 3S 3S 3S 3S 3C 2C 2C 2C 2M 1M 1M 1A 4A 4A 4 sorry it was not B 2 its C 2 .SELECT DISTINCT Co1, Col2FROM Table1if i execute above query the order will cahnge.I want exact order as my output likeS 3C 2M 1A 4$atya.Love All Serve All. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 06:51:03
|
Please do tell us which constitutes the order of the records in your table. E 12°55'05.63"N 56°04'39.26" |
 |
|
Dev@nlkss
134 Posts |
Posted - 2009-04-24 : 07:10:56
|
Sorry If i am not clear.The alphabets are under column NAME and numerics are under VALUE.S --> 3C --> 2M --> 1A --> 4The output should be as above order.because VALUE 3 contains sortID as 1 as same for all.$atya.Love All Serve All. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 07:19:52
|
Where is the SORTID column? E 12°55'05.63"N 56°04'39.26" |
 |
|
Dev@nlkss
134 Posts |
Posted - 2009-04-24 : 07:35:53
|
NAME - VALUE - SortIDS 3 1 S 3 2S 3 3S 3 4S 3 5C 2 6C 2 7C 2 8C 2 9M 1 10M 1 11M 1 12A 4 13 A 4 14A 4 15 as above Value 3 contains Sortid as 1 thus it should come first and under VALUE 3 there are 5 items as sortids from 1-->5 then 6th item starts for 2nd value thus it should come second and so on...As i require only NAME And VALUE Columns so i can have either min or max from each group but order must be same.$atya.Love All Serve All. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 07:39:20
|
Now, FINALLY, we have enough information to proceed.SELECT Name, ValueFROM Table1GROUP BY Name, ValueORDER BY MIN(SortID)Now, this wasn't so hard, was it? To provide enought information so that a solution is possible. E 12°55'05.63"N 56°04'39.26" |
 |
|
Dev@nlkss
134 Posts |
Posted - 2009-04-24 : 07:49:28
|
Thanks.The same way i did but i dont know where i have gone wrong.any how i got solution.Thanks again.$atya.Love All Serve All. |
 |
|
|
|
|