Reputation: 841
I am required to count all the instances of quotes in the system based on the following criteria for table .
Table 1
Quote Number | Quote Version |
1 | A
1 | A
2 | B
2 | C
So you may see 2 quotes . Apparently I need to count 3 Not 2 , as I need to consider the different quote versions as an individual quotes.
So I was thinkin od adding a column say Quote Count and adding a 1 for every occurance of a quote , but sure how to structure it in sql ?
I need to add the number of quotes in this table at a later point in the process so thought i could just go to this column and do a count of the records in table with a Quote Count=1 .
Upvotes: 0
Views: 47
Reputation: 5244
SELECT COUNT(*)
FROM (
SELECT DISTINCT [Quote Number], [Quote Version]
FROM Table1
) s
No need to add a column, it is easily achieved with a query
Upvotes: 3