zeeshanmbutt
Programmer
Quick help with a select query
Hi All,
I have a table called #Tempp with the following fields & types.
saledate(datetime),pricezonename(nvarchar),storeid(nvarchar),productid(nvarchar),SHPrice(decimal),PSPrice(decimal)
This #Tempp have the following type of records.
saledate,pricezonename,storeid,productid,SHPrice,PSPrice
2007-02-04,SouthSide_City,4138,1-01200000157-000,1.89,1.89
2007-02-04,SouthSide_City,4126,1-01200000157-000,1.75,1.89
2007-02-04,SouthSide_City,4110,1-01200000157-000,1.75,1.89
2007-02-04,SouthSide_City,4157,1-01200000157-000,1.75,1.89
As you can see the #Tempp table tells what is the SHPrice & PSPrice per product; per date; per zone; and per outlet.
I want to display the records per date,per zone, where the SHPrice is different than the PSPrice.
That is, using the above data I want to display the following fields & records (as in above example).
saledate,pricezonename,count(productid) ProductCount, CountWherePricesAreDiff
2007-02-04,SouthSide_City,4,3
Here we can note the following,
1)ProductCount is 4 since there are '4 sets of SHPrice & PSPrice' per date per zone for that productid '1-01200000157-000'.
2)I want to create a field 'CountWherePricesAreDiff' which in this example would be 3, since there are 3 places where the 'SHPrice & PSPrice' are differnt for that productid '1-01200000157-000' per zone per date.
How can I Create this 'CountWherePricesAreDiff' field?
Can somepne please provide me the TSQL script for that?
Please let me know.
Thanks a million....
Hi All,
I have a table called #Tempp with the following fields & types.
saledate(datetime),pricezonename(nvarchar),storeid(nvarchar),productid(nvarchar),SHPrice(decimal),PSPrice(decimal)
This #Tempp have the following type of records.
saledate,pricezonename,storeid,productid,SHPrice,PSPrice
2007-02-04,SouthSide_City,4138,1-01200000157-000,1.89,1.89
2007-02-04,SouthSide_City,4126,1-01200000157-000,1.75,1.89
2007-02-04,SouthSide_City,4110,1-01200000157-000,1.75,1.89
2007-02-04,SouthSide_City,4157,1-01200000157-000,1.75,1.89
As you can see the #Tempp table tells what is the SHPrice & PSPrice per product; per date; per zone; and per outlet.
I want to display the records per date,per zone, where the SHPrice is different than the PSPrice.
That is, using the above data I want to display the following fields & records (as in above example).
saledate,pricezonename,count(productid) ProductCount, CountWherePricesAreDiff
2007-02-04,SouthSide_City,4,3
Here we can note the following,
1)ProductCount is 4 since there are '4 sets of SHPrice & PSPrice' per date per zone for that productid '1-01200000157-000'.
2)I want to create a field 'CountWherePricesAreDiff' which in this example would be 3, since there are 3 places where the 'SHPrice & PSPrice' are differnt for that productid '1-01200000157-000' per zone per date.
How can I Create this 'CountWherePricesAreDiff' field?
Can somepne please provide me the TSQL script for that?
Please let me know.
Thanks a million....