Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,
i have a table i want to arrange this table value given code formate

it is Status table
statuscode	        statusid	StatusCount

Just Received	           1	         7
Sent to Engineer	   2	        30
Estimation Not Approved	   4	         2
Under QC	           9	        17
QC Passed	           10	         1
Ready for Delivery	   11          159
Delivered to Customer	   13	       288
Reallocated to Engineer	   17	         1
Sent to HO / RO	           20	         3
Allocated to CSO	   21	         1
Pending For Estimation	   38	        21
Pending For Engineer Estimation	39	40
Pending For Estimation Approval	40	65
Estimation Approved	   41	        17
Pending Payment	           42	        48
Sent To QC Unrepaired	   43	        10
Payment Received	   44	        22


how to arreange by statuscode

Just Received
Pending For Estimation
Pending For Engineer Estimation
Pending For Estimation Approval
Estimation Not Approved	
Sent to Engineer
Under QC
QC Passed
Pending Payment	
Payment Received
.
.
.
.
.
.
Posted

You cannot rearrage these columns. What you can do is you can add a new column DisplayOrder in whic you say the order in which it is to be displayed.
statuscode	        statusid	StatusCount   DisplayOrder
 
Just Received	           1	         7             1
Sent to Engineer	   2	        30
Estimation Not Approved	   4	         2             5
Under QC	           9	        17             6
QC Passed	           10	         1
Ready for Delivery	   11          159
Delivered to Customer	   13	       288
Reallocated to Engineer	   17	         1
Sent to HO / RO	           20	         3
Allocated to CSO	   21	         1
Pending For Estimation	   38	        21              2
Pending For Engineer Estimation	39	40              3
Pending For Estimation Approval	40	65              4
Estimation Approved	   41	        17
Pending Payment	           42	        48
Sent To QC Unrepaired	   43	        10
Payment Received	   44	        22



Then when retrieveing You can say
SQL
select statuscode from status order by displayorder
 
Share this answer
 
v2
Comments
DINESH K MAURYA 9-Oct-12 3:23am    
thank,
trying it.
can be short row if row value like this..
a,b,c,d
arrange it a,c,b,d
Santhosh Kumar Jayaraman 9-Oct-12 3:25am    
I didnt get your question
DINESH K MAURYA 9-Oct-12 3:41am    
suppose i have a table name tb
and column name
alphabate
and his rows value like
a
b
c
d
arrange it
a
c
b
d
Add another column for status code and sort order by status code when select records
 
Share this answer
 
You will need to either add a column which provides the sort order, or write a monolithic CASE statement:
SQL
SELECT * FROM MyTable
   ORDER BY
     CASE statuscode
     WHEN 'Just Recieved' THEN 1
     WHEN 'Pending For Estimation' THEN 2
...
     ELSE 9999
     END
I would add the column, myself!
 
Share this answer
 
create new table,
table = ProcessFlow
No   ProcessName
1    Just Received
2    Pending For Estimation
3    Pending For Engineer Estimation
4    Pending For Estimation Approval
5    Estimation Not Approved	
6    Sent to Engineer
7    Under QC
8    QC Passed
9    Pending Payment	
10   Payment Received
.
.
.


join your table with processFlow table
like below
SQL
select statuscode, statusid, StatusCount
from tbl
left join ProcessFlow on ProcessFlow.ProcessName=statuscode
Order by 
ProcessFlow.No


Tips, easy way is in your table statuscode should be numbers and join tables using this nos. and display processname
it will save memory


Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900