hi - im trying to return the minimum value from selected columns. however for some non obvious reason it only works when 3digit long numbers are entered in to the columns in question. [i.e Price_Band_1, Price_Band_2, Price_Band_3 & Price_Band_4]
the below code returns 100 when it really should return 2... any ideas as to why? -
FLIGHTROUTES = "Select CheapestPrice = MIN(CheapestPrice) from (" & _
-
-
"Select MIN(Price_Band_1) As CheapestPrice from TEST where Id in (1,2,3) " & _
-
"UNION ALL " & _
-
"Select MIN(Price_Band_2) from TEST where Id in (1,2,3) " & _
-
"UNION ALL " & _
-
"Select MIN(Price_Band_3) from TEST where Id in (1,2,3) " & _
-
"UNION ALL " & _
-
"Select MIN(Price_Band_4) from TEST where Id in (1,2,3) " & _
-
-
")x"
-
this is my table -
ID Flight_Route Price_Band_1 Month_Band_1 Date_Band_1 Price_Band_2 Month_Band_2 Date_Band_2 Price_Band_3 Month_Band_3 Date_Band_3 Price_Band_4 Month_Band_4 Date_Band_4
-
1 EDMONTON to GATWICK 99 July 13, 20 2 Aug 27 85 Sept 28 108 Oct NO FLIGHT 'YEG','LGW' <a name="YEGLGW"></a>
-
2 GATWICK to EDMONTON 100 July 20, 27 4 Aug 24 99 Sept 21, 28 350 Oct NO FLIGHT 'YEG','LGW' <a name="YEGLGW"></a>
-
3 HALIFAX to GATWICK 99 July 15, 22 9 Aug 5 101 Sept 30 999 Oct NO FLIGHT 'YHZ','LGW' <a name="YHZLGW"></a>
-
the exact same sql statement/code works perfectly for another table but as mentioned above all of its 'Price_Band's have values higher than 100...
please advise
Omar.
5 2591
What is the type of all the Price_Band_X columns? It looks like they are text types instead of numeric types.
hi Christopher - thanks for the quick reply. they are set to varchar(50) rather than int as sometimes a N/A value is required to be input in the table
Right, so of course the string "100" is less than the string "2". You need to cast those values in the comparison. You also need to filter out those "N\A" values. I do not know if you developed the DB but in the future, use numeric types where appropriate to avoid situations like this. Is "N/A" really "required" to be input into the table? I don't think that would ever be a valid business or functional requirement. It sounds like a convention that was agreed on as a valid solution when all you really needed to do was allow nulls in that field or use some integer value, like -1, that could be filtered out in queries.
ok no worries - I'll set these columns to type integer & to allow nulls.
then if the column = NULL then I'll replace with N/A via asp
thanks again
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Porthos |
last post by:
Hi All,
I'm trying to find the minimum value of a set of data (see below).
I want to compare the lengths of these attribute values and display
the lowest one.
This would be simple if I could...
|
by: Dennis |
last post by:
In CSS3 it looks like we'll have multiple column flowing of text
(newspaper style) in which the number of columns can be determined
automatically given the available horizontal space....
|
by: Billy Jacobs |
last post by:
I am using a datagrid to display some data. I need to
create 2 header rows for this grid with columns of
varying spans. In html it would be the following.
<Table>
<tr>
<td colspan=8>Official...
|
by: RobG |
last post by:
I would like a query that will tell me the minimum non-zero value in a
row.
Say I have a table with a column called recordID that contains unique
record IDs, and have a set of values named V1,...
|
by: simchajoy2000 |
last post by:
Hi,
I am trying to use a VB.NET listview object to display information
from a datatable. I need to have two columns of information but I
don't want the user to be able to select each column...
|
by: John Devlon |
last post by:
Hi,
Does anyone know how to get a value of a second column of a selected item
in Listview.
I've create a listview and added this code
Listview.Items.Clear()
Listview.Columns.Clear()...
|
by: ray well |
last post by:
i need to display 2 columns of data in a list box.
how would i set this up IN CODE.
say my table is tblNames, and i have 2 fields, FirstName, LastName, and want
the data to show up in 2...
|
by: Will |
last post by:
Can someone help with code to delete multiple columns from an excel
spreadsheet? I know which columns I need to delete. The code below will
delete a single column but I'm not sure how to delete...
|
by: Soniad |
last post by:
Hello,
In stored procedure, i am using query that fetches 2 columns record but single row. i have used cursor to fetch single record.
is there any way to fetch the record and put it in...
|
by: omar999 |
last post by:
i can a max value of a single column with where clause like this
select MAX(Price_Band_1) AS HighestPrice from UK_Specials where ID IN (1,3,5,7,9,10,13,15,17,19,21,23,25,27,29,31,33,35,37)
...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |