Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have have written dataset for retrieving data directly from stored procedure .

OUTPUT-- After executing Stored procedure output is coming like this.

3RD PARTY SUPPLIER	422	60	40
CONTRACTOR	        808	43	57
EQUIPMENT SERVICE	260	85	15


I am displaying in fronted in same format as above output in grid view. but in grid view i need to display data this below order-


CONTRACTOR	    808	 43	57
3RD PARTY SUPPLIER  422	 60	40  
EQUIPMENT SERVICE   260	 85	15


This is the SP-----

declare @Total as table (SC_SupplierCategoryName Nvarchar(100),PG_TotalAntExend int,PG_PercMadeinOmanTotal int)
insert into @Total(SC_SupplierCategoryName,PG_TotalAntExend,PG_PercMadeinOmanTotal)
select 'CONTRACTOR', SUM(PG_TotalAntExend)as total1, SUM(PG_TotalAntExend*PG_PercMadeinOman)/SUM(PG_TotalAntExend) as PG_PercMadeinOmanTotal
from TR_ICV_PlanningGoods
where SC_SupplierCategoryID in (1,4) and ICV_ID in(select ICV_ID from TM_ICV where icv_supplier_contractID=@ContractNumber)
group by  SC_SupplierCategoryID
		
	

--declare @Total as table (SC_SupplierCategoryName Nvarchar(100),PG_TotalAntExend int,PG_PercMadeinOmanTotal int)

insert into @Total(SC_SupplierCategoryName,PG_TotalAntExend,PG_PercMadeinOmanTotal)
select '3RD PARTY SUPPLIER', SUM(PG_TotalAntExend)as total1, SUM(PG_TotalAntExend*PG_PercMadeinOman)/SUM(PG_TotalAntExend) as PG_PercMadeinOmanTotal
from TR_ICV_PlanningGoods
where SC_SupplierCategoryID in (2,5) and ICV_ID in(select ICV_ID from TM_ICV where icv_supplier_contractID=@ContractNumber)
group by  SC_SupplierCategoryID




insert into @Total(SC_SupplierCategoryName,PG_TotalAntExend,PG_PercMadeinOmanTotal)
select 'EQUIPMENT SERVICE', SUM(PG_TotalAntExend)as total1, SUM(PG_TotalAntExend*PG_PercMadeinOman)/SUM(PG_TotalAntExend) as PG_PercMadeinOmanTotal
from TR_ICV_PlanningGoods
where SC_SupplierCategoryID in (3) and ICV_ID in(select ICV_ID from TM_ICV where icv_supplier_contractID=@ContractNumber)
group by  SC_SupplierCategoryID

--select * from @Total

select SC_SupplierCategoryName , sum(PG_TotalAntExend) as Total_Expenditure, 
(sum(PG_TotalAntExend*PG_PercMadeinOmanTotal)/sum(PG_TotalAntExend)) as Made_in_Oman, 
100 - (sum(PG_TotalAntExend*PG_PercMadeinOmanTotal)/sum(PG_TotalAntExend)) as Not_Made_In_Oman

from @Total  group by SC_SupplierCategoryName 
Posted
Updated 7-Apr-14 1:30am
v3
Comments
[no name] 7-Apr-14 7:29am    
And your question is what? So get the data sorted in a descending order on the second field in your query.
kamalsekhar 7-Apr-14 7:36am    
Hi,
I have posted my Quiery. please see it once . i want to display data in grid view this below order. i m retrieving data from stored procedure in dataset. how to do order like this ?

CONTRACTOR 808 43 57
3RD PARTY SUPPLIER 422 60 40
EQUIPMENT SERVICE 260 85 15

Include order by SC_SupplierCategoryName in your final query in stored proc. You can also use Sort option provided in DataTable and DataView depending on what you are using.

http://stackoverflow.com/questions/11029823/dataset-sorting[^]
 
Share this answer
 
 
Share this answer
 
SQL
//change below
group by SC_SupplierCategoryName to group by SC_SupplierCategoryName order by  SC_SupplierCategoryName

it will solve your problem. Let try it and reply if it helps or not
 
Share this answer
 
Comments
kamalsekhar 7-Apr-14 8:49am    
hi sukanta,
Its not working, same as previous order output.

CONTRACTOR 808 4 57
EQUIPMENT SERVICE 260 85 15
THIRD PARTY SUPPLIER 422 60 40

I need like this order--

CONTRACTOR 808 43 57
THIRD PARTY SUPPLIER 422 60 40
EQUIPMENT SERVICE 260 85 15
Suk@nta 7-Apr-14 9:02am    
then change to order by Total_Expenditure desc
It seems your o/p is in descending order of Total_Expenditure ?
you can apply
order by Total_Expenditure desc
 
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