I'm trying to display a list of all Deliveries with the status
Dispatched
. However, its only returning the number value
of the status
as opposed to the actual string value
. I think this is because I have used Enum
to store my status values
?
I wish to display the word Dispatched
instead of the number value
that it represents in the Enum
.
I'm developing in ASP.Net MVC and I'm using the query builder
in VS2013.
I'm not sure how to approach this, can anyone please suggest an easy to understand solution using SQL.
Let me know if any additional code is required, and thank you in advance!
Here's the Query I want but it doesn't work:
SELECT Delivery.[Status],
COUNT(Delivery.DeliveryID) AS Dispatched_Status
FROM Delivery
WHERE Delivery.[Status] = 'Dispatched'
GROUP BY Delivery.[Status];
Here's the Query that does work but returns a number value. I tried it this way because Enum stores the string value as a number:
SELECT Delivery.[Status],
COUNT(Delivery.DeliveryID) AS Dispatched_Status
FROM Delivery
WHERE Delivery.[Status] = '1'
GROUP BY Delivery.[Status];
P.S I'm aware that status
is a reserved word - will be following the correct naming conventions in future.
Delivery Table Definion