|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Filter on one column but display another
I have a date column and a value column. I want to display the value column based on the last date. MAX (Date)
I tried using MAX for the date column but that displays the last date. Any Ideas? |
|
#2
|
|||
|
|||
|
Code:
select v
from t
where d in (
select max(d)
from t)
|
|
#3
|
|||
|
|||
|
Select Distinct value from table order by date
this sounds like what you are looking for, if not, just elaborate a bit and I or someone else here may be able to help you. |
|
#4
|
|||
|
|||
|
This is the script
--Query to return list price for product by product family--
SELECT prf.description as PRICE_FAMILY, pdf.description as PRODUCT_FAMILY, pro.code as ITEM_NUMBER, pro.description as PRODUCT, uom.description as UOM, uom.conversion_factor as COUNT, lst.price as LIST_PRICE, pro.cost as OVERRIDE_COST_EACH, rci.price_received as LAST_COST from product_families pdf join products pro on (pdf.pdf_id = pro.pdf_id and pdf.pdf_source_id = pro.pro_source_id) join packaged_products pkp on (pkp.pro_id = pro.pro_id and pkp.pkp_source_id = pro.pro_source_id) join units_of_measure uom on (pkp.uni_id = uom.uni_id and pkp.uni_source_id = uom.uni_source_id) join receipt_items rci on (pkp.pkp_id = rci.pkp_id and pkp.pkp_source_id = rci.pkp_source_id) join price_families prf on (prf.prf_id = pro.prf_id and prf.prf_source_id = pro.prf_source_id) LEFT outer join list_prices lst on (pkp.pkp_id = lst.pkp_id and pkp.pkp_source_id = lst.pkp_source_id) where pkp.delivery = 'Y' and pro.out_service_date is NULL -- and rci.price_received in (select MAX (rci.datetime_posted)) ORDER BY pdf.description ASC, pro.product ASC I do not know if this will help but I still can not get it. I have a database that keeps up with the purchase price of goods, so everytime it is purchased it adds a line to the table to put in the purchase price and the post time. I want to get the last post time to populate my price. |
|
#5
|
|||
|
|||
|
Code:
SELECT prf.description as PRICE_FAMILY, pdf.description as PRODUCT_FAMILY, pro.code as ITEM_NUMBER, pro.description as PRODUCT, uom.description as UOM, uom.conversion_factor as COUNT, lst.price as LIST_PRICE, pro.cost as OVERRIDE_COST_EACH, rci.price_received as LAST_COST from product_families pdf join products pro on (pdf.pdf_id = pro.pdf_id and pdf.pdf_source_id = pro.pro_source_id) join packaged_products pkp on (pkp.pro_id = pro.pro_id and pkp.pkp_source_id = pro.pro_source_id) join units_of_measure uom on (pkp.uni_id = uom.uni_id and pkp.uni_source_id = uom.uni_source_id) join receipt_items rci on (pkp.pkp_id = rci.pkp_id and pkp.pkp_source_id = rci.pkp_source_id) join price_families prf on (prf.prf_id = pro.prf_id and prf.prf_source_id = pro.prf_source_id) LEFT outer join list_prices lst on (pkp.pkp_id = lst.pkp_id and pkp.pkp_source_id = lst.pkp_source_id) where pkp.delivery = 'Y' and pro.out_service_date is NULL and rci.datetime_posted in ( select MAX (datetime_posted) from receipt_items) ORDER BY pdf.description ASC, pro.product ASC |
|
#6
|
|||
|
|||
|
That's it! Thank you so much for your help.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Filter on one column but display another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|