Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DATE


DATE

Author
Message
angelreynosog
angelreynosog
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 85
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

Attachments
AYUDA.jpg (7 views, 287.00 KB)
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44871 Visits: 39850
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
LutzM
LutzM
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 7001 Visits: 13559
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search