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

Serial Numbers in Union Query

Hello,

How to create serial numbers in Union Query??

i have merged 5 querys on union query as per Code Tag. Just i need serial numbers as per data stored in union query.

i have searched some of Row_Number Topics & tryhing that but can't workout. Could you please replay anyone how to do this??


Expand|Select|Wrap|Line Numbers
  1. SELECT PAY_1.ID, Format(PAY_1.PayNo,  "\P-B0000") As PayNo, PAY_1.PayDate, PAY_1.R_Mode, PAY_1.ChqDDNo, Null AS ChqPassRej, PAY_1.Amount AS Withdraw, Null AS Deposit
  2. FROM PAY_1
  3. WHERE (((PAY_1.R_Mode) Like "NEFT" Or (PAY_1.R_Mode) Like "Advance Draft" Or (PAY_1.R_Mode) Like "RTGS" Or (PAY_1.R_Mode) Like "Cheque" Or (PAY_1.R_Mode) Like "DD"));
  4.  
  5. UNION ALL
  6.  
  7. SELECT PAY_2.ID, Format(PAY_2.PayNo,  "\P-A0000") As PayNo, PAY_2.PayDate, PAY_2.R_Mode, PAY_2.ChqDDNo, Null AS ChqPassRej, PAY_2.Amount AS Withdraw, Null AS Deposit
  8. FROM PAY_2
  9. WHERE (((PAY_2.R_Mode) Like "NEFT" Or (PAY_2.R_Mode) Like "Advance Draft" Or (PAY_2.R_Mode) Like "RTGS" Or (PAY_2.R_Mode) Like "Cheque" Or (PAY_2.R_Mode) Like "DD"));
  10.  
  11. UNION ALL
  12.  
  13. SELECT REC_1.ID, Format(REC_1.RecNo,  "\R-A0000") As RecNo, REC_1.RecDate, REC_1.R_Mode, REC_1.ChqDDNo, Null AS ChqPassRej, Null AS Withdraw, REC_1.Amount AS Deposit
  14. FROM REC_1
  15. WHERE (((REC_1.R_Mode) Like "NEFT" Or (REC_1.R_Mode) Like "Advance Draft" Or (REC_1.R_Mode) Like "RTGS" Or (REC_1.R_Mode) Like "Cheque" Or (REC_1.R_Mode) Like "DD"));
  16.  
  17. UNION ALL 
  18.  
  19. SELECT REC_2.ID, Format(REC_2.RecNo,  "\R-B0000") As RecNo, REC_2.RecDate, REC_2.R_Mode, REC_2.ChqDDNo, Null AS ChqPassRej, Null AS Withdraw, REC_2.Amount AS Deposit
  20. FROM REC_2
  21. WHERE (((REC_2.R_Mode) Like "NEFT" Or (REC_2.R_Mode) Like "Advance Draft" Or (REC_2.R_Mode) Like "RTGS" Or (REC_2.R_Mode) Like "Cheque" Or (REC_2.R_Mode) Like "DD"));
  22.  
  23. UNION ALL 
  24.  
  25. SELECT BT_MainQry.ID, Format(BT_MainQry.TrNo,  "\BT0000") As TrNo, BT_MainQry.TrDate, BT_MainQry.Particulars, BT_MainQry.ChqTNo, BT_MainQry.ChqPassdRej, BT_MainQry.Withdraws, BT_MainQry.Deposits
  26. FROM BT_MainQry;
May 27 '15 #1
4 1270
Seth Schrock
2,965 Expert 2GB
If you are trying to have the count run through the whole query, then you will have to have your current query run as a subquery and have the record numbering happen in the main query.
May 27 '15 #2
NeoPa
32,556 Expert Mod 16PB
This isn't something you can easily do with a query as quries especially, and databases generally, work around Set Theory. The results are a set of items. The order of those items is not determinable until after the items are returned.

There are probably ways you can encourage the system to create incrementing numbers for you, but that all depends on what you're doing.
May 27 '15 #3
Yes, i have tried a Subquery with DCount Condition. its showing total counting numbers only can't run the serial number wise... :( :( :(

i have attached the dB file Can you please see once and go to Query: BT_Qry1 this query source from Query: BT_UnionQry1.
Just i want to add Serial Numbers in the above both of querys BT_Qry1 or BT_UnionQry1 as per data storing wise.

Thanks
Attached Files
File Type: zip SB1 BT.zip (795.4 KB, 74 views)
May 28 '15 #4
NeoPa
32,556 Expert Mod 16PB
I'm afraid you won't find many people here incautious enough to download a db that hasn't even been asked for.

As a general rule you are expected to explain your situation in words where possible. Clearly and succinctly. A great benefit of working in Access is that it's very rarely not possible as queries are all stored as SQL, which is text.
May 29 '15 #5

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

Similar topics

3
by: Paradigm | last post by:
I am using Access 2K as a front end to a MYSQL database. I am trying to run a Union query on the MYSQL database. The query is (much simplified) SELECT as ID from faxdata UNION SELECT as ID ...
3
by: Stewart Allen | last post by:
Hi there I'm trying to find part serial numbers between 2 numbers. The user selects a part number from a combo box and then enters a range of serial numbers into 2 text boxes and the resulting...
4
by: Missy | last post by:
We’ve recently upgraded our computer system to XP. My union query (which was working perfectly for years) now returns hieroglyphics instead of invoice numbers. When I run the 2 queries...
2
by: mattytee123 | last post by:
I have about 20 tables, of which I would like to do a union query and count of how many of each different code there is? The simplified verson of the table is structured like this. Code ...
3
by: Sim Zacks | last post by:
I am using 8.0 beta 1 on an RH 8 Linux server. I have a union query that I am converting from access (where it worked) and it is returning duplicates. The only difference between the two rows is...
8
by: kepston | last post by:
I have a situation where I need to record scrap quantities for parts that we sell and parts that are supplied, in a single table. I have a UNION query that combines the part numbers successfully,...
2
blyxx86
by: blyxx86 | last post by:
Great insight needed!! Good evening everyone.. I've come to a point where I can't even fathom how to go forward. I'm attempting to create a serialized inventory. I don't know where to begin....
4
by: N2Deep | last post by:
I have a table named SUPPORT DATA, I have a field named Serial Number. In the Serial Number field I have many duplicates, and I only want one of each. Sample serials ABB045000MG, JBX05050016 ...
2
by: Sandhya1988 | last post by:
Hello friends, How to set a serial number format with text in union query? I was tried to some of number formats in union query so some formats is working good some of formats is not working in...
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?
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
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
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...

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.