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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sort in View

Author  Topic 

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-03-14 : 03:53:29
How I can sort data in View by some parameters?
Thanks in advance!

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-14 : 04:04:56
Do you mean order by clause ??

you can use Case else conditions in ur order by clause to sort...



Sucess Comes to those who Believe in Beauty of their Dream..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-14 : 04:05:04
why do you want to do this, sort it in you query using that view

select *
from yourview
order by somecol


----------------------------------
'KH'


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-14 : 04:05:27
Do you want to pass column name and sort it accordingly?. It is not possible from View.
Give more details

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-03-14 : 04:15:22
I have:
CREATE VIEW dbo.vPayers
AS
SELECT PayerID, PayerName, NotePayer, PayerClass, CONVERT(NVARCHAR(10), PayerProcent) + '%' AS PayerProcent,
PayerAttrib, ReserveColor, SettlementColor,
case PayerType
WHEN 1 THEN 'ïîñòîÿííûé'
ELSE 'âðåìåííûé'
END AS PayerType,
case PayerType
WHEN 1 THEN 0
ELSE 14417920
END AS Color,
LastUserName, LastTimeModification
FROM Payers

I need to sort by PayerName.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-14 : 04:26:07
You can do this
CREATE VIEW dbo.vPayers
AS
SELECT TOP 100 PERCENT
PayerID, PayerName, NotePayer, PayerClass,
CONVERT(NVARCHAR(10), PayerProcent) + '%' AS PayerProcent,
PayerAttrib, ReserveColor, SettlementColor,
case PayerType
WHEN 1 THEN 'ïîñòîÿííûé'
ELSE 'âðåìåííûé'
END AS PayerType,
case PayerType
WHEN 1 THEN 0
ELSE 14417920
END AS Color,
LastUserName, LastTimeModification
FROM Payers
ORDER BY PayerName


BUT you should be do this instead
select *
from vPayers
order by PayerName



----------------------------------
'KH'


Go to Top of Page

hornet
Yak Posting Veteran

96 Posts

Posted - 2006-03-14 : 04:28:58
thanks a lot! Working
Go to Top of Page
   

- Advertisement -