SQL Query..Query

Associate
Joined
11 Mar 2005
Posts
1,168
Afternoon all,

I have an sql problem which I cant sort out.. mainly 'cos I dont know anything!

My table, data_out contains 7 columns: with 31313 rows of data...

on_link
to_time
count
mean_speed
length_c
fuel_consumption
carbon_dio

I'd like to construct a query that does as below

FOR each instance of to_time (distinct??)

SUM count * length_c as output_1

AND

SUM fuel_consumption as output_2

AND

SUM mean_speed as output_3

Right.. that probably makes absolutely no sense whatsoever - but any ideas?

Possibly point me in the right direction!

Cheers
 
Not too sure I have understood correctly, but guess its something like this:

SELECT TO_TIME, SUM(LENGTH_C) AS OUTPUT 1, SUM(FUEL_CONSUMPTION) AS OUTPUT 2, SUM(MEAN_SPEED) AS OUTPUT 3, COUNT(*)
FROM DATA_OUT
GROUP BY TO_TIME
 
try this...

Code:
SELECT 
	SUM(Count * Length_C) AS Output_1,
	SUM(Fuel_Consumption) AS Output_2,
	SUM(Mean_Speed) AS Output_3
FROM Data_Out 
GROUP BY To_Time
HTH
 
Last edited:
Thanks chaps!

I think both will work - but the problem I have is that some of the fields are encapsulated with " " - meaning that sql is interpreting them as a text string?

Is there a way to globally change text strings to say an integer or decimal,

I've tried using the cast as decimal, integer and that works... but not in conjunction.

Any ideas?
 
Back
Top Bottom