Showing posts with label price. Show all posts
Showing posts with label price. Show all posts

Sunday, March 11, 2012

A stored procedure

Hello!
Could anyone help me with this stored procedure...!?
Table Cars:
-Id
-Model
-Make
-Year
...
Table PriceList
-Id
-CarId
-Price
...
I would like to select all fields from "Cars" and only MIN(Price) from
"PriceList" WHERE Cars.Id = PriceList.CarId. and join them into a single
result set.
Thanks!
JamesHello,
Try with
SELECT id, Model, Make, Year, (SELECT MIN(Price) FROM PriceList WHERE CarId
= c.Id)
FROM Cars c
Regards,
Tomislav Kralj
"James T." <gimenei@.hotmail.com> wrote in message
news:uSyVIOUKFHA.572@.tk2msftngp13.phx.gbl...
> Hello!
> Could anyone help me with this stored procedure...!?
> Table Cars:
> -Id
> -Model
> -Make
> -Year
> ...
> Table PriceList
> -Id
> -CarId
> -Price
> ...
> I would like to select all fields from "Cars" and only MIN(Price) from
> "PriceList" WHERE Cars.Id = PriceList.CarId. and join them into a single
> result set.
> Thanks!
> James
>

Thursday, March 8, 2012

A simple calculation ?

I have rows of data in a VB DataGrid with the following fields

Product, Price/Unit, # of Units.

I want to be able to display these fields plus an extended value to calculate the Price/Unit * # of Units.

This seems like it should be easy, I'm just getting a little mixed up with the Syntax.

Any help would be appreciated.

Thanks in advance

tattoo

You are writing the syntax yourself.
select Product, PricePerUnit, NumberOfUnits, PricePerUnit * NumberOfUnits as TotalPrice
from ...|||Works perfectly thank you

Friday, February 24, 2012

A query to get n values from one column

I have a query which join 5 tables say my result is
Warehouse ProductName Features Price Manf
I just need to make some analysis and need to select any 5 features
from Features column for each productname. There can be 10 - 50
features mentioned in the table with features.
Say my result it like only for productname and features column
which come from diff tables. Here I am getting more than 5 features
I need to reduce that to 5 for each. So how do I do this.
Productname Features
AAAAA 12
AAAAA 145
AAAAA 23
AAAAA 34234
AAAAA 234234
AAAAA 32234
AAAAA 134234
AAAAA 21
AAAAA 14
AAAAA 556
BBBBB 19
BBBBB 23
BBBBB 6
BBBBB 1
BBBBB 2
BBBBB 11
BBBBB 15
BBBBB 12
BBBBB 6
BBBBB 4
Also very important this need to be done is how do i avoid repititions
and do the cross- tab join and make only one row for one product name
and get the result like this
Productname Features
AAAAA 12, 45, 234, 256, 25677, 24223......
BBBBB 12,121, 144, 58885, 8888, 99999....
CCCCC 111, 144, 2333, 22333, 22221......Please search the archives of this newsgroup to see if there is any
alternatives. For instance, check today's thread "comma delimited list".
Anith

Thursday, February 16, 2012

a price range dimension question

I'm using sql2k.
I'm providing a simplified scenario here.
I'm trying to build a fact table on sales (ie. item, price, quantity,
price*quantity).
I'd like build a cube that I can look up the price by range ($0-$5,
$5-10, $10-$15, etc...).
What's the best way to handle this? do i need a price range
dimension? or should i keep the price range in fact table?
I can't predict what new price will be added to sales, it could be
from 1 cent to any pricing, so if I were to build a price range
dimension, how would it look like?=== Steve L === wrote:
> I'm using sql2k.
> I'm providing a simplified scenario here.
> I'm trying to build a fact table on sales (ie. item, price, quantity,
> price*quantity).
> I'd like build a cube that I can look up the price by range ($0-$5,
> $5-10, $10-$15, etc...).
> What's the best way to handle this? do i need a price range
> dimension? or should i keep the price range in fact table?
> I can't predict what new price will be added to sales, it could be
> from 1 cent to any pricing, so if I were to build a price range
> dimension, how would it look like?
>
--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
I believe the price range would be considered more a criteria than a
dimension. The only price-range dimension table I could come up w/
would be something like this:
CREATE TABLE PriceRange (
range_code INT NOT NULL PRIMARY KEY,
start_value DECIMAL (11,2) NOT NULL,
end_value DECIMAL (11,2) NOT NULL
)
The fact table would hold the range_code. When you made the CUBE you'd
include the range_code. It might be faster to use range_codes if all
you're doing is a retrieval of data based on ranges. Probably, you
could include both range_code and price in the cube.
But, it make more sense to only use the price in the CUBE then you could
do SUMs and change the price range criteria for each query. Using the
PriceRange dimension - what happens when you want to change the range
criteria of a query? The PriceRange dimension would have to be rebuilt,
then the cube. Are you always going to be using the same price ranges?
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQuVvxYechKqOuFEgEQJxJACgwYIakvQZsqvI
WzXp1z6A6aFyMN8An3VU
aJ07XYAO+lukEymGqGnn8aQe
=E0wk
--END PGP SIGNATURE--|||Hi Steve ,
This might solve your problem
Here the gap is 10 ,You can easily make it 5 ,qty can be changed to
price
SELECT LowRange,HiRange,COUNT(*)
FROM (SELECT lowRange = ((qty - 1) / 10) * 10 + 1
,HiRange=((qty - 1) / 10) * 10 + 10
FROM sales) AS ds
GROUP BY lowRange ,HiRange
Please let me know if it solved your purpose
With warm regards
Jatinder