Hi everyone,
I am working on project that I am trying to query a SQL database to generate a report. In the database I have a table named "Item". That table is made up of three attributes: Item_UID(primary key), Item_ID (general ID) and Description.
I am trying to query the database in such a way that the report will include the Item_ID, the Description and a count of distinct Item_UID such as:
_________________
Item_ID: 0001
Description: blue pen
Quantity:50
-------------------------
I am working with WPF and C# and I came up with a pseudo code that I am still not sure if it will work:
ListOfItems = select distinct (Item_ID) from Item; for each(element in ListOfItems){ Quantity = select count(distinct Item_UID) from Item where Item_ID = element; Desc = select Description from Item where Item_ID = element; }
"Quantity" and "Desc" would be variables that store the result of the query.
I want to get a list of the different Item category and for each category I want to obtain its description and the number of items that fall under it.
I know the Pseudo code is not fully correct but I hope you understand what I am trying to do.
Thanks in advance.