Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

SQL Query to Count Distinct

$
0
0

Hi All,

I would need your help to count distinct in Totals.

Problem Statement:

Invoice Data.

to simplify the problem let us assume a Country had only 1 invoice generated for a day and it had 2 Items.

1 from Food Category and 1 from ALC category.

When I write count of Invoice at Country level (group by Country) I get 1 Invoice but when I add Category in group by it gives 1 in ALC and 1 in FOOD which is correct. What I need is 1 for ALC and 1 for FOD and a Total ROW with 1 since total is at Country level and number should match irrespective of Levels 


AJ


Viewing all articles
Browse latest Browse all 4729

Trending Articles