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)
 Order By Issue

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-02 : 08:36:10
Dear ALL,
I Have The Following Columns In a table

This Earning And Deductions Elements are Fixed


Employee Earning Element Deduction Element

000002 Production Incentive Vehicle Loan Repayment
000002 Monthly Perform Allowance Salary Advance
000002 Medical Monthly Proffessional Tax
000002 Leave Travel Allowance Personal Loan Repayment
000002 Increment Arrear Miscellaneous Deduction
000002 House Rent Allowance Income Tax
000002 Conveyance Employees Contri PF
000002 Basic Salary Canteen Deduction

000003 Production Incentive Vehicle Loan Repayment
000003 Monthly Perform Allowance Salary Advance
000003 Medical Monthly Proffessional Tax
000003 Leave Travel Allowance Personal Loan Repayment
000003 Increment Arrear Miscellaneous Deduction
000003 House Rent Allowance Income Tax
000003 Conveyance Employees Contri PF
000003 Basic Salary Canteen Deduction


But I need the Output In following order.

Employee Earning Element Deduction Element

000002 Basic Salary Employees Contri PF
000002 House Rent Allowance Proffessional Tax
000002 Conveyance Canteen Deduction
000002 Monthly Perform Allowance Income Tax
000002 Medical Monthly Vehicle Loan Repayment
000002 Leave Travel Allowance Salary Advance
000002 Increment Arrear Miscellaneous Deduction
000002 Production Incentive Personal Loan Repayment

000003 Basic Salary Employees Contri PF
000003 House Rent Allowance Proffessional Tax
000003 Conveyance Canteen Deduction
000003 Monthly Perform Allowance Income Tax
000003 Medical Monthly Vehicle Loan Repayment
000003 Leave Travel Allowance Salary Advance
000003 Increment Arrear Miscellaneous Deduction
000003 Production Incentive Personal Loan Repayment

How Can I do The Same

Thanks and Regards
Krishnakumar.C

tishri
Yak Posting Veteran

95 Posts

Posted - 2006-09-02 : 08:48:49
select * from table1 order by Employee,Earning asc

TCC
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-02 : 08:52:36
please look on the order it's not a perfect ascending order
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-02 : 08:52:51
Thanks !! please look on the order it's not a perfect ascending order
Go to Top of Page

tishri
Yak Posting Veteran

95 Posts

Posted - 2006-09-02 : 09:01:57
w/c column that is not to be sorted in ascending order?

you can also do this type of query

select * from table1
order by Employee,Earning asc, Deduction desc


TCC
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-02 : 09:05:42
it's some what nearest but not exact....!
Go to Top of Page

tishri
Yak Posting Veteran

95 Posts

Posted - 2006-09-02 : 09:13:37
the only sorted column in your example is the [Employee] column.

i think you need to have a separate table for the columns,... Earning Element Deduction Element
then join them using a key



TCC

TCC
Go to Top of Page

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2006-09-02 : 09:23:05
Okay!! Thanks
Go to Top of Page
   

- Advertisement -