I am sorry,
I did not mention that I am using "SELECT DISTINCT" statement.
This does not permit you to use a column in the order by clause that is not in the Select clause.
ROUND(CAST((1+(.06))*(tbl_products.pprice)as Decimal (10,2)),2) as taxprice,
ROUND(CAST((1+(.02))*(((1+(.06))*(tbl_products.pprice))*(tbl_material_used.mqty))as Decimal (10,2)),2) as total
In the first case
NJ 2003-08-04 09:51:47.667 has the most latest timestamp than "CO". so 1st "CO" record would be ignored. In the 2nd case there is only 1 record for date "08/26"
ie, "CO 2003-08-26 11:01:58.743"
So this would appear in the resultset.
No, I want the output as shown.
NJ can appear twice in mycase.
Your query would ignore one of my "NJ" records.
I want all the latest records for that day.
I have DATETIME stamp in columnB.
I want all the latest rows for a particular date.
ColumnA ColumnB
------------------
NJ 2003-06-30 10:22:02.700
CO 2003-08-04 09:49:13.247
NJ 2003-08-04 09:51:47.667
CO 2003-08-26 11:01:58.743
FL 2004-10-09 11:48:13.610
FL 2004-10-09 11:50:13.610
For e.g...
In Sql Server, if I want to update a column based on the next row data from another column in 1 query how is this possible ?
e.g. :
I have a data like this : I want to populate ColumnC with ColumnB next row data.
Can I write a dynamic query that would be used to populate ColumnC otherwise I...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.