dbTalk Databases Forums  

Question

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Question in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
skc
 
Posts: n/a

Default Question - 11-12-2003 , 10:03 AM






I am trying to export data out of a table that contains
text field types.

Here is the SQL:


SELECT 1, 2, First(3) as First_Date, Last(4) as Last_date,
SUM(val([5])) as Sum_Qty
FROM Results
Group By 1, 2

Field 3 and 4 contain dates in the format date/time but
are in a text datatype. I am trying to get the first day
(from left) and the last day (from right) for those dates,
as the table contains data for the month of January, so I
am only interested from the 1st to 31st (or whatever).

Furthermore, field5 contains a number that needs to get
summed. I want the output grouped by 1 and 2.

The above was experimented in Access2000, but this does
not work in SQL2000 - as I am a learner!!

Please can someone help me with the query above as I am
stuck.

SKC

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Question - 11-12-2003 , 08:23 PM






Can you show us a row of data?

All attributes that are in a select clause with an aggreagate function that
are not part of an aggregate will need to grouped by.

--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"skc" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am trying to export data out of a table that contains
text field types.

Here is the SQL:


SELECT 1, 2, First(3) as First_Date, Last(4) as Last_date,
SUM(val([5])) as Sum_Qty
FROM Results
Group By 1, 2

Field 3 and 4 contain dates in the format date/time but
are in a text datatype. I am trying to get the first day
(from left) and the last day (from right) for those dates,
as the table contains data for the month of January, so I
am only interested from the 1st to 31st (or whatever).

Furthermore, field5 contains a number that needs to get
summed. I want the output grouped by 1 and 2.

The above was experimented in Access2000, but this does
not work in SQL2000 - as I am a learner!!

Please can someone help me with the query above as I am
stuck.

SKC



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.