I have a table with multiple columns.’Product Name’ being one. Table has records for multiple products. product name is also used in a free text field. I need reports on how many rows have a particular product listed in ‘Product Name’or in ‘Free text’ fields.
Table as below :
Product Name | Issue description |
---|---|
Microsoft | outlook not working |
Lenovo | laptop blue screen |
Samsung | microsoft word issu |
I need the results as below :
Product | number of records |
---|---|
Microsoft | 2 ( one for outlook issue and other for word issue on a different product) |
I need the product ( could be an alias), but need ‘Microsoft’ in the results
Is this achievable ?
I tried sub queries using ‘WITH’ and AS. Doesn’t work.
I’m using a reporting tool with freehand sql. Could not achieve with sub-queries. Appreciate any guidance.
2
Answers
You can achieve this using a UNION to combine results from both the Product Name and the Issue Description columns. Here’s a SQL query that should work for your case: