Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

DATE Expand / Collapse
Author
Message
Posted Saturday, October 19, 2013 10:33 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 8:46 AM
Points: 6, Visits: 47
Hi all,
WOULD IF I CAN HELP WITH THAT, I HAVE MY INNER JOIN TABLE EXISTENCIA_BODEGA WITH THE TABLES AND CELLAR TRANSACCION_INV, I WANT TO BRING IS ALL THAT HAD LAST ARTICLE TRANSACTION, SO HAVE FECHA_HORA_TRANSAC COLUMN, BUT I IS BRINGING ALL THE TRANSACTION, COULD GUIDE ME ON HOW I CAN TELL ME BRING SQL TRANSACTIONS OF EVERY lAST ARTICLE.

HOW CAN SEE I HAVE A COLUMN BETWEEN A FECHA_HORA_TRANSAC FOR ME TO BRING THE 17/10/2013 2013-10-01, SHOULD COMPLY WITH THESE CONDITIONS.

THANK YOU,

GREETINGS


  Post Attachments 
AYUDA.jpg (7 views, 287.52 KB)
Post #1506435
Posted Saturday, October 19, 2013 10:41 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:43 AM
Points: 35,371, Visits: 31,913
To help us help you, rather than posting a picture of the data, please see the first link under "Helpful Links" in my signature line below and post your data as per that article. Otherwise the answer is simply, express a ROW_NUMBER() over the partitions formed by the articulo column in descending order by fecha_hora_transac in a CTE and select only the rows with a ROW_NUMBER() of "1" from that.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1506436
Posted Sunday, October 20, 2013 5:25 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 3:13 PM
Points: 6,842, Visits: 13,364
It looks like something along those lines might help (untested due to missing sample data in a ready to use format...):
WITH cte AS
(
SELECT DISTINCT articulo
FROM unknown
)
SELECT
uk.articulo,
uk.bodega,
uk.cant_disponible,
uk.cantidad,
uk.fecha_hora_transac
FROM cte
CROSS APPLY
(
SELECT TOP 1
u.articulo,
u.bodega,
u.cant_disponible,
u.cantidad,
u.fecha_hora_transac
FROM unknown u
INNER JOIN cte ON cte.articulo = u.articulo
ORDER BY u.fecha_hora_transac DESC
)uk

If there's already a normalized table to get the articulo values, use this table instead of the cte.




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1506466
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse