473,418 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

help with cast function on sql statement

120 100+
using sql and asp and need a little bit of help please. I'm calculating the cheapest prices from 3 columns which works fine

working sql statement
Expand|Select|Wrap|Line Numbers
  1. CARHIRE = "Select CheapestPrice = MIN(CheapestPrice) from " & _
  2. "(Select MIN(Fully_Inclusive_Weekly_Price_Band_1) As CheapestPrice from National_Car_Prices UNION ALL" & _
  3. " Select MIN(Fully_Inclusive_Weekly_Price_Band_2) from National_Car_Prices UNION ALL" & _
  4. " Select MIN(Fully_Inclusive_Weekly_Price_Band_3) from National_Car_Prices )x"
  5.  
but I also need to apply a cast function on the final value I output - just a simple division by 7. this is my attempt
Expand|Select|Wrap|Line Numbers
  1. CARHIRE = "Select CheapestPrice = MIN(CheapestPrice = Cast (CheapestPrice / 7 as dec (10,0)) from " & _
  2. "(Select MIN(Fully_Inclusive_Weekly_Price_Band_1) As CheapestPrice from National_Car_Prices UNION ALL" & _
  3. " Select MIN(Fully_Inclusive_Weekly_Price_Band_2) from National_Car_Prices UNION ALL" & _
  4. " Select MIN(Fully_Inclusive_Weekly_Price_Band_3) from National_Car_Prices )x"
  5.  
error

Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near '='.

thanks in advance
Omar
Oct 10 '10 #1

✓ answered by ck9663

Try converting this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. MIN(CheapestPrice = Cast (CheapestPrice / 7 as dec (10,0)) 
  3.  
  4.  
to

Expand|Select|Wrap|Line Numbers
  1.  
  2. MIN(Cast (CheapestPrice / 7 as dec (10,0)))
  3.  
  4.  
Happy Coding!!!

~~ CK

3 1836
NeoPa
32,556 Expert Mod 16PB
Why don't you start by posting the actual SQL the engine attempted to process, and the full error details including line and character. That's not complicated is it.
Oct 11 '10 #2
ck9663
2,878 Expert 2GB
Try converting this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. MIN(CheapestPrice = Cast (CheapestPrice / 7 as dec (10,0)) 
  3.  
  4.  
to

Expand|Select|Wrap|Line Numbers
  1.  
  2. MIN(Cast (CheapestPrice / 7 as dec (10,0)))
  3.  
  4.  
Happy Coding!!!

~~ CK
Oct 11 '10 #3
omar999
120 100+
CK your solution worked perfectly! thank you

my attempt wasnt too far off - syntax all wrong though!

thanks again : )
Oct 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alex | last post by:
I am having difficulty writing a SQL statement and I was wondering if one of you gurus could help me. I have a table that has three fields: InvoiceID, Item, ItemPrice. Each InvoiceID is associated...
7
by: VPaul | last post by:
I hope I am posting to the correct group for assistance. Please advise me if there is another group I should go to. I am new to this, so I apologize if I don't explain this very well. I do...
10
by: Barbrawl McBribe | last post by:
Is is possible to use typedefs to cast function pointers? I think I saw this in the WINGs src; grep for '(hashFunc)'. So far, trying to use a typedef to cast function pointers so that a return...
0
by: T. J. Fan | last post by:
I was trying to call from a web page a routine defined in another page (to reload that page). More specifically, I need to be able to reload the first page after user did something on the second...
5
by: AMDRIT | last post by:
I would like to cast an object to a value type specified by a variable of Type Function ReturnTest(InputVar as Object) as Object Dim DataType as Type = GetType(System.String) If TypeOf...
10
by: WaterWalk | last post by:
*Hope this thread doesn't violate this group's rule* I found the following code in the GNOME's glib-2.12 source: /* In gclosure.c */ GClosure* g_cclosure_new (GCallback callback_func,...
0
by: gordonro | last post by:
I was told that i could use the SET statement along with the CAST statement to convert a UTF-8 data stream into an EBCDIC stream in my COBOL program. Is this possible? If so, how is it coded? ...
1
by: preeti13 | last post by:
Hi friends i need a help with if statement iam try to do if record is exist then display the msg but getting the error .The type or namespace name 'Exist' could not be found (are you missing a using...
4
by: omar999 | last post by:
I have the following cast function which multiplys a column value by 1.1 to display on a webpage. SELECT *, Twin_Band_1 = Cast( Twin_Band_1 * 1.1 as int) FROM MYTABLENAME WHERE ID = '1'" if...
20
by: omar999 | last post by:
is it possible to perform a cast function on an entire table via sql? im basically trying to select all table contents multiply by 1.1 and then display the converted data on a webpage using sql,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.