473,654 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Consolidate Rows?

77 New Member
Expand|Select|Wrap|Line Numbers
  1. CASE_ID BEFORE BETWEEN AFTER       
  2. 53222     N       N      Y
  3. 53222     Y       N      N
  4. 53222     Y       N      N
  5. 53222     Y       N      N
  6. 53222     Y       N      N
  7. 53222     Y       N      N
  8. 53222     Y       N      N
  9. 54233     Y       N      N
  10. 54233     Y       N      N
  11. 54233     Y       N      N
  12. 54233     Y       N      N
  13. 54375     Y       N      N
  14. 54375     Y       N      N
  15. 54375     Y       N      N
  16. 54375     Y       N      N
  17. 54375     Y       N      N
  18. 54375     Y       N      N
  19. 54375     Y       N      N
  20. 54375     Y       N      N
  21. 54992     Y       N      N
  22. 54992     Y       N      N
  23. 54992     Y       N      N
  24. 54992     Y       N      N
  25. 54992     Y       N      N
  26. 54992     Y       N      N
  27. 54992     Y       N      N
Please help.

I have a query with the above data. I want to consolidate it and have a row for each distinct Case_ID based on the following condition,

BEFORE column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'

BETWEEN column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'

AFTER column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'.

So for Case_ID = 53222 abd 54233, the consolidated rows should look like,

53222, Y, N, Y
54233, Y, N, N

Thanks in advance
Dec 12 '07 #1
3 2449
NeoPa
32,568 Recognized Expert Moderator MVP
Try :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Case_ID],
  2.        Max([Before]) AS [MaxBefore],
  3.        Max([Between]) AS [MaxBetween],
  4.        Max([After]) AS [MaxAfter]
  5. FROM [Query]
  6. GROUP BY [Case_ID]
BTW I'm assuming your post should have read :
BEFORE column = 'Y', if any of the rows for that Case_ID has a 'Y', else BEFORE column = 'N'

BETWEEN column = 'Y', if any of the rows for that Case_ID has a 'Y', else BETWEEN column = 'N'

AFTER column = 'Y', if any of the rows for that Case_ID has a 'Y', else AFTER column = 'N'.
Dec 12 '07 #2
AccessHunter
77 New Member
It worked, thank you so much.
Dec 13 '07 #3
NeoPa
32,568 Recognized Expert Moderator MVP
No problem :)
Pleased to help.
Dec 13 '07 #4

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

Similar topics

3
4001
by: Andrew Chanter | last post by:
I have a table containing multiple records per key. eg: 1 | John Smith 1 | Mary Brown 1 | Julie Grey 2 | Danny Pink 2 | Jill White I need to consolidate this into a single record for each key, eg.
1
1633
by: Dalan | last post by:
Trying to determine the best approach to use in consolating multiple records in an Access 97 Db. The users submit updates in HTML format generated from a query that are in turn imported into a master database. There are 50+/- records each that are submitted by a substantial number of users with each periodic update. The output does include the user ID reference and the date prepared, but as a query has no header, the information is...
1
1432
by: deko | last post by:
How can I consolidate these two tables into a single view? Current: =TableA= fldP fldX =TableB= fldY
1
1797
by: Bob | last post by:
I have been asked to modify an existing Access database so that it can update a MySQL databse in head office from multiple MS Access databases in branches. The idea is that when the HO database is available then any changes made in branch will automatically update HO but when HO database is not available then changes are 'batched' until it is available and then update. (There is a Virtula Private Network involved in this). The update is...
2
1277
by: Raj | last post by:
Hi All, I have a method call GetStationListenUrl that exists as three overloaded methods 1) public static string GetUrl( int strength, string strengthNavigateUrl, zzz.StreamRow sra, string bandName) 2) public static string GetUrl( int strength, string strengthNavigateUrl, xxx.StreamsRow sra, string bandName)
1
2853
by: Sasikala | last post by:
Hi, I have a view which selects these columns: employeenumber,ClientID,Billing code,amountBilled,InvoiceNumber from a number of other tables. One Employee may have many billingAmounts. My view right now has each row for every Amount Billed for each Employee.I want to have a query which has only one row for each employee with repeating cloumns if they have multiple billings. If an employee A has one row in the view,i want my output in...
14
2023
by: --CELKO-- | last post by:
Can I get a little help? Given a very simple table of events, with their durations, I want to consolidate time periods for an event that (1) touch each other or (2) overlap each other. CREATE TABLE Events (event_id VARCHAR(25) NOT NULL, start_date DATE NOT NULL, end_date DATE NOT NULL, CHECK (start_date <= end_date), PRIMARY KEY (event_id, start_date, end_date));
7
1286
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for windows application. I have 2 solutions that I would like to consolidate into and have just one installation .msi for them, is this possible? So I just just copy and move one of the solution's project file into the other one and create additional setup file in it? Thanks. -- Thanks.
11
1721
by: MahaCoder | last post by:
Given the following table: EMPL_ID | CO_ID | START | STOP -------------------------------------------- 12 U 01/06/1976 07/09/1980 12 U 03/18/1982 11/18/1988 12 U 03/23/1988 05/01/1992 12 U 01/25/1991 02/29/1996 12 U 03/16/2004 05/05/2004 12 U 05/06/2004 12/31/9999
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.