Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 SQL Query of rpackage

Author  Topic 

Oliviaf2012
Starting Member

16 Posts

Posted - 2012-09-26 : 06:16:22
Hi
I am runnnig a query as follows :

SELECT count(distinct(address2_fax)) As IE from AllActiveAuthorised
WHERE [Country Code] = ('IE')
AND allowmail = 'Allow'
and statuscode = '1'
AND l2g_brandname = 'Viviscal Max' AND
l2g_dispatcheddate >= CONVERT(DATETIME, '2012-09-01 00:00:00', 102)
AND l2g_dispatcheddate <= CONVERT(DATETIME, '2012-10-01 00:00:00', 102)

and I want to run this for a number of countries and display all the results together - this works ok in Management Studio as all results are shown one after the other but in SSIS I want the results output to a csv file.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-26 : 06:54:33
If you remove the WHERE condition on country code and group by country code, it should return data all the countries. You may want to order the results by country code so you can easily look up countries in the CSV file.
SELECT [Country Code],
COUNT(DISTINCT(address2_fax)) AS [Count]
FROM AllActiveAuthorised
WHERE allowmail = 'Allow'
AND statuscode = '1'
AND l2g_brandname = 'Viviscal Max'
AND l2g_dispatcheddate >= CONVERT(DATETIME, '2012-09-01 00:00:00', 102)
AND l2g_dispatcheddate <= CONVERT(DATETIME, '2012-10-01 00:00:00', 102)
GROUP BY
[Country Code]
ORDER BY
[Country Code];
Go to Top of Page

Oliviaf2012
Starting Member

16 Posts

Posted - 2012-09-26 : 07:11:54
Fantastic
Go to Top of Page
   

- Advertisement -