Hi,
I'm write a stored procedure where i want to display null values at the bottom of
each department.
Scenario
------------------------------------
ID | Name | cost | Dept |
---|----------------|------|-------|
1 | a | 15 | 1 |
2 | b | 10 | 1 |
nul| Total | 25 | |
5 | c | 5 | 2 |
nul| Total | 5 | |
7 | d | 2 | 3 |
nul| Total | 2 | |
------------------------------------
in @tbl i'm fetch all the values from the order table
n
in @tbl2 i'm fetching the total of sum(cost) using group by dept.
then i have used union all
select * from @tbl
union all
select * from @tbl1
This one is displaying null values first values, order by dept.
But i want to display first values then null values,
order by dept(eg. as above table).
can any one please help me to get this table in sql where i can display null values
at the bottom of each department.
Thanks