473,386 Members | 1,745 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,386 software developers and data experts.

need help to understand two pieces of codes

Who can help me to understand the following two queries? They are very
useful when you want to show data horizontally. I found it from a Chinese
Access website.

----------------------------------------------------------------------------
--
Sql codes:

query1

SELECT DCount("*","table1","[id]<=" & [id]) AS ID, table1.Bank,
Table1.Amount
FROM table1;

query2

SELECT Max(IIf([ID] Mod 5=1,[Bank])) AS Bank1, Sum(IIf([ID] Mod
5=1,[Amount])) AS Amount1, Max(IIf([ID] Mod 5=2,[Bank])) AS Bank2,
Sum(IIf([ID] Mod 5=2,[Amount])) AS Amount2, Max(IIf([ID] Mod 5=3,[Bank])) AS
Bank3, Sum(IIf([ID] Mod 5=3,[Amount])) AS Amount3, Max(IIf([ID] Mod
5=4,[Bank])) AS Bank4, Sum(IIf([ID] Mod 5=4,[Amount])) AS Amount4,
Max(IIf([ID] Mod 5=0,[Bank])) AS Bank5, Sum(IIf([ID] Mod 5=0,[Amount])) AS
Amount5
FROM query1
GROUP BY ([ID]-1)\5;
----------------------------------------------------------------------------
------

For me it is very difficult to understand
1£®GROUP BY ([ID]-1)\5
2£®Max(IIf([ID] Mod 5=1,[Bank]))
many thanks,

Paul

Nov 13 '05 #1
2 1073
"Paul T. Rong" <et***@hotmail.com> wrote in message
news:O5******************@news.chello.at...
Who can help me to understand the following two queries? They are very
useful when you want to show data horizontally. I found it from a Chinese
Access website.


This is one way of doing crosstabs in sql engines that don't support
crosstabs directly. With Jet you have the TRANSFORM .. PIVOT statement which
is neater and probably faster as well. Incidentally, the next version of SQL
Server, (Yukon, now in beta), also supports PIVOT (at last).
Nov 13 '05 #2
Thanks for infomation. It is quite slow indeed. I decided not to use them.
Paul
"John Winterbottom" <as******@hotmail.com> дÈëÏûÏ¢ÐÂÎÅ
:2t*************@uni-berlin.de...
"Paul T. Rong" <et***@hotmail.com> wrote in message
news:O5******************@news.chello.at...
Who can help me to understand the following two queries? They are very
useful when you want to show data horizontally. I found it from a Chinese Access website.

This is one way of doing crosstabs in sql engines that don't support
crosstabs directly. With Jet you have the TRANSFORM .. PIVOT statement

which is neater and probably faster as well. Incidentally, the next version of SQL Server, (Yukon, now in beta), also supports PIVOT (at last).

Nov 13 '05 #3

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

Similar topics

14
by: Droolboy | last post by:
Hi. Due to the massive amount of choices in free php-based cms-systems, I thought I'd ask this group for help picking the right one. I don't need/want a fullblown portal tool. What i'm looking...
21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
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++...
4
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or...
5
by: Confused User | last post by:
I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business...
6
by: news | last post by:
I need some concise, easy to grok examples of what .Net (preferably C#.Net) has over just using old ASP or PHP with JavaScript. See, I'm a PHP guy, and while I started server-side scripting with...
4
by: dismantle | last post by:
Hi all, this is my 3rd week in studying VB codes and i came across with this codes from a online tutorial about classes. Public Function MiddleInitial() As String MiddleInitial =...
2
by: Academia | last post by:
I'm using ITextRange::FindText Method and it works OK but I have to code so that if the return is not equal to S_OK means it succeeded. Does VB.NET do some thing to the HRESULT before I get it?...
15
by: fyi | last post by:
My new blog on bits and pieces of PHP coding. http://bitspiecesphp.blogspot.com/ Have used all of them. Hope they're as useful to others: Use PHP to track email sender from your web site...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.