what is the use of case statement
-
I have a table named as depot_mstr having attributes, are the following--- regn, depot_code, depot_name, city I have also an another table as dealer_list having attributes, are the following--- depot_no, depot_code, dealer_name, dealer_category how i get the output as--- regn| depot_code| dealer_name| GC| SC| STA| OTH where, GC, SC, STA, OTH are the elements of dealer_category
-
I have a table named as depot_mstr having attributes, are the following--- regn, depot_code, depot_name, city I have also an another table as dealer_list having attributes, are the following--- depot_no, depot_code, dealer_name, dealer_category how i get the output as--- regn| depot_code| dealer_name| GC| SC| STA| OTH where, GC, SC, STA, OTH are the elements of dealer_category
Assuming you are using sql server:
SELECT regn, depot_code, dealer_name, GC, SC, STA, OTH
FROM
(SELECT regn, depot_mstr.depot_code, dealer_name, dealer_category FROM depot_mstr LEFT
JOIN dealer_list ON depot_mstr.depot_code = dealer_list.depot_code
) AS sourcetable
PIVOT
(
COUNT (dealer_category)
FOR dealer_category IN
(GC, SC, STA, OTH)
) AS pivottable -
Assuming you are using sql server:
SELECT regn, depot_code, dealer_name, GC, SC, STA, OTH
FROM
(SELECT regn, depot_mstr.depot_code, dealer_name, dealer_category FROM depot_mstr LEFT
JOIN dealer_list ON depot_mstr.depot_code = dealer_list.depot_code
) AS sourcetable
PIVOT
(
COUNT (dealer_category)
FOR dealer_category IN
(GC, SC, STA, OTH)
) AS pivottablePlease also send me the code as early as possible, if i solve it through function in sql server... Thank u...
-
Assuming you are using sql server:
SELECT regn, depot_code, dealer_name, GC, SC, STA, OTH
FROM
(SELECT regn, depot_mstr.depot_code, dealer_name, dealer_category FROM depot_mstr LEFT
JOIN dealer_list ON depot_mstr.depot_code = dealer_list.depot_code
) AS sourcetable
PIVOT
(
COUNT (dealer_category)
FOR dealer_category IN
(GC, SC, STA, OTH)
) AS pivottableI can't find any case using in the query....!!!