SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 24th, 2003, 08:29 PM
tikbalang tikbalang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 tikbalang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Select sum case group?

I want to retrieve all the 'unitmodule' where 'datesent' and 'datedelivered' value are not equal to Null from 'logistics' table group by 'unitmodule'.

logistics tables
ID unitmodule datesent datedelivered
1 PSU June 1, 2003 June 31, 2003
2 AFE May 12, 2002
3 AFE March 5, 2002 April 3, 2002
4 CSU
5 TRX May 4, 2004

output
unitmodule Module sent Module delivered
PSU 1 1 AFE 2 1 TRX 1 0 CSU 0 0

this is what i did:
<%
accessdb="bss"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")

sql = "select
unitmodule,
sum(case when datesent Is Null then 0 else 1 end) as datesentcount,
sum(case when datedelivered Is Null then 0 else 1 end) as datedeliveredcount,
from
logistics
group by unitmodule;"

rs.Open sql, cn
If rs.eof then
search="nothing"
end if
%>

the error message was:
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/test/defectivecount2xxx.asp, line 72

sql = "select
-------------^

I'm sure I'm writing it the wrong way. thanks.

Reply With Quote
  #2  
Old August 24th, 2003, 08:35 PM
tikbalang tikbalang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 tikbalang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
repost

I want to retrieve all the 'unitmodule' where 'datesent' and 'datedelivered' value are not equal to Null from 'logistics' table group by 'unitmodule'.

logistics tables
ID unitmodule datesent datedelivered
1 PSU June 1, 2003 June 31, 2003
2 AFE May 12, 2002
3 AFE March 5, 2002 April 3, 2002
4 CSU
5 TRX May 4, 2004

output
unitmodule Module sent Module delivered
PSU 1 1
AFE 2 1
TRX 1 0
CSU 0 0

this is what i did:
<%
accessdb="bss"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")

sql = "select
unitmodule,
sum(case when datesent Is Null then 0 else 1 end) as datesentcount,
sum(case when datedelivered Is Null then 0 else 1 end) as datedeliveredcount,
from
logistics
group by unitmodule;"

rs.Open sql, cn
If rs.eof then
search="nothing"
end if
%>

the error message was:
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/test/defectivecount2xxx.asp, line 72

sql = "select
-------------^

I'm sure I'm writing it the wrong way. thanks.

Reply With Quote
  #3  
Old August 24th, 2003, 10:04 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
think of the query in english, you said it perfecly, you want all the records WHERE 'datesent' and 'datedelivered' value are not equal to Null from 'logistics'. So put that into your where clause, and check to make sure those two columns are not NULL. =P

unterminated string constant, you have to do your query like this

Code:
strSQL = "SELECT " & _
            "blah from blah " & _


you have to close the string and then continue the string to the next line with & _, hope this helps, let me know if you still can't get it..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Select sum case group?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway