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

I need a lot of help with a DB2 query

Hello,

I'm sure there is someone here way smarter than me. I need help with a big to me query.

I would like to perform a query that gets the information I need and then join a count of some more information to the end of the output. (I know clear as mud)

Here's what I have so far,
Expand|Select|Wrap|Line Numbers
  1. select a.rule, b.account, count(*) from Table1 a, Table2 b, Table3 c where c.rule = a.rule and a.month = DEC and a.rule > 0 and b.account_type != '*' group by b.account_type, a.rule;
This is the output,

118 TYPE A 100
118 TYPE B 20
118 TYPE C 200

I would like to add (a join I think) another column at the end of the report to include a count of the month that matches each account type where the rule is less than 1.

I know this would be very easy for someone but it seems to be escaping me.

Thanks in advance
Jan 23 '08 #1
1 1162
Hello,

I'm sure there is someone here way smarter than me. I need help with a big to me query.

I would like to perform a query that gets the information I need and then join a count of some more information to the end of the output. (I know clear as mud)

Here's what I have so far,
Expand|Select|Wrap|Line Numbers
  1. select a.rule, b.account, count(*) from Table1 a, Table2 b, Table3 c where c.rule = a.rule and a.month = DEC and a.rule > 0 and b.account_type != '*' group by b.account_type, a.rule;
This is the output,

118 TYPE A 100
118 TYPE B 20
118 TYPE C 200

I would like to add (a join I think) another column at the end of the report to include a count of the month that matches each account type where the rule is less than 1.

I know this would be very easy for someone but it seems to be escaping me.

Thanks in advance
One easy way is to nest a select statement

select a.rule, b.account, count(*),

(select count(*) from table y where x.month = y.month and x.account_type = y.account_type and y.rule < 1)

from table1 a, table2 b, ..............................
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: Nick | last post by:
Deear All, I would be thankful if you could help me with the following query. I have two tables TableA and TableB TableA Name: David Address: 123 West Side City: New York
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
10
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
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:
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.