Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default VBA error while using SQL "with rollup"

Hi,

It would be so grateful if anyone can help me on the below issue.

I am using an SQL string to extract the data from SQL server, here I
have to sort the data in excel exactly like when we are using "with
rollup" in SQL (or like pivot table in excel, but this is very
difficult for my project).

My query look like this:
SqlStr = "Select Distinct LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
From scorecard" & _
" Where LOB = 'BILLING'" & _
" group By LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
with rollup"

but when I'm using this, I am getting below error:

Run-time error '-2147217900 (80040e14)':
Incorrect syntax near the keyword 'with'. If this statement is a
common table expresssion or an xmlnamesspaces clause, the previous
statement must be terminated with a semicolon.



Many thanks in advance.
Ratheesh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default VBA error while using SQL "with rollup"

I haven't used the Rollup - so, apologies if there is no value in my
post but:
- do you need the DISTINCT in there?
- which field is supposed to be totalled up with the Rollup if in you
sql it seems that every field is being grouped by...? Don't you need a
field that has an aggregate function?
Also, when googling i found this:
ROLLUP doesn't support DISTINCT in aggregate functions or the GROUP BY
ALL clause.




On Jan 11, 2:04*pm, Ratheesh wrote:
Hi,

It would be so grateful if anyone can help me on the below issue.

I am using an SQL string to extract the data from SQL server, here I
have to sort the data in excel exactly like when we are using "with
rollup" in SQL (or like pivot table in excel, but this is very
difficult for my project).

My query look like this:
SqlStr = "Select Distinct LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
From scorecard" & _
* * * * * * * " Where LOB = 'BILLING'" & _
* * * * * * * * " group By LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
with rollup"

but when I'm using this, I am getting below error:

Run-time error '-2147217900 (80040e14)':
Incorrect syntax near the keyword 'with'. If this statement is a
common table expresssion or an xmlnamesspaces clause, the previous
statement must be terminated with a semicolon.

Many thanks in advance.
Ratheesh


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default VBA error while using SQL "with rollup"

On Jan 11, 7:41*pm, AB wrote:
I haven't used the Rollup - so, apologies if there is no value in my
post but:
- do you need the DISTINCT in there?
- which field is supposed to be totalled up with the Rollup if in you
sql it seems that every field is being grouped by...? Don't you need a
field that has an aggregate function?
Also, when googling i found this:
ROLLUP doesn't support DISTINCT in aggregate functions or the GROUP BY
ALL clause.

On Jan 11, 2:04*pm, Ratheesh wrote:







Hi,


It would be so grateful if anyone can help me on the below issue.


I am using an SQL string to extract the data from SQL server, here I
have to sort the data in excel exactly like when we are using "with
rollup" in SQL (or like pivot table in excel, but this is very
difficult for my project).


My query look like this:
SqlStr = "Select Distinct LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
From scorecard" & _
* * * * * * * " Where LOB = 'BILLING'" & _
* * * * * * * * " group By LOB,THIRDPARTY_FLAG,LANGUAGE,CENTRE_NAME
with rollup"


but when I'm using this, I am getting below error:


Run-time error '-2147217900 (80040e14)':
Incorrect syntax near the keyword 'with'. If this statement is a
common table expresssion or an xmlnamesspaces clause, the previous
statement must be terminated with a semicolon.


Many thanks in advance.
Ratheesh


Hi AB,

Thanks for your reply.
DISTINCT is mandatory here for my data, else it would repeat so many
times.
Actually there is no issues with distinct while using group by or
rollup in SQL. The only issue when I'm using the same string in VBA.
I'm not able to identify what could be the reason....!

Can anyone experience this issue.. please help...

Many thanks
Ratheesh
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Coult not find specified object" and "Path-File access error" messages Robert Crandal Excel Programming 3 December 19th 09 09:12 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
"Clean Me" Macro is giving "#VALUE!" error in the Notes field. Ryan Watkins Excel Programming 1 June 11th 05 12:25 AM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM


All times are GMT +1. The time now is 06:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"