473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Sorry: Trying to understand this piece of code

I have this piece of script and I'm trying to understand what the
'SET t.Z_ASSOC_ROW = (t.rowid - m.MinRowID) + 1'
and the 'INNER JOIN' line is doing
UPDATE t
SET t.Z_ASSOC_ROW = (t.rowid - m.MinRowID) + 1
FROM tassoc t
INNER JOIN (SELECT Booking,MIN(rowid) AS 'MinRowID'
FROM tassoc
GROUP BY Booking) m
ON m.Booking = t.Booking

table 'tassoc'
rowid booking z_assoc_row
1 38 0
2 40 0
3 41 0
4 42 0
5 43 0
6 44 0
7 53 0
8 53 0
9 102 0
10 103 0
11 103 0
Jul 20 '05 #1
1 1463
It might be clearer if you convert this proprietary code into equivalent
Standard SQL:

UPDATE Tassoc
SET z_assoc_row = rowid + 1
-
(SELECT MIN(rowid)
FROM Tassoc AS M
WHERE booking = Tassoc.booking)

This enumerates multiple rows for each booking by setting z_assoc_row = 1
for the first row for the booking and incrementing on subsequent rows. The
sequence is based on Rowid. If the Rowid's for a booking are not consecutive
then the sequence will have gaps.

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: forgotten field | last post by:
Hi,how are you? I have been studying C++ by myself, but recently I am having a real problem. I am learning about the basic usage of a doubly linked list using polymorphism. However, I have got the...
9
by: TCMA | last post by:
I am looking for some tools to help me understand source code of a program written in C++ by someone else. Are there any non-commercial, open source C or C++ tools to reverse engineer C or C++...
12
by: Will Ferrer | last post by:
I am looking to get started using PHP and I am looking for a nice GUI to use. Basically I have been programing in Macromedia Director, and Macromedia Flash for years now, and I have gotten spoiled...
13
by: Terry Andersen | last post by:
Could anyone please help me understand what is going on in the code below. A short explanation would be nice..... Best Regards Terry struct mystruct { unsigned char testchar; unsigned short...
51
by: Richard Hengeveld | last post by:
Hi all, I'm trying to understand how pointers for function parameters work. As I understand it, if you got a function like: void f(int *i) { *i = 0; }
2
by: DC | last post by:
Hi, I need to asynchronously read from a network (TCP) stream, and I am having trouble with retrieving whole blocks; I get a break in the data block every 1460 bytes which relates to network...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
by: badboybrown | last post by:
Hello folks, I found this piece of code on this group by Dorman Blackman: > Function BusinessDays(dDate1, dDate2) As Long > BusinessDays = (DateDiff("d", dDate1, dDate2) - _ > ...
22
by: MLH | last post by:
I would like to test some of this code in the debug window... Option Compare Database Option Explicit Private Sub Command0_Click() #If Win32 Then MsgBox "Hey! It's WIN32." #End If End Sub
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.