Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select SQl query for more then 1 record

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
There are 5 Accounts in a Table and want to get all sale transactions from sale table in one cursor of all five accounts through Select SQL .

e.g.
Accounts Table Name = [Acnts]

Sale Table Name = [SaleH]

Record1 Code = [00001AAA]

Record2 Code = [00002BBB]

Record3 Code = [00003CCC]

Record4 Code = [00004DDD]

Record5 Code = [00005EEE]

 
The typical table structure of accounts and sales is having two tables accounts and sales.

To get all sales you only do SELECT * FROM sales, you may want to sort by account, but that even doesn't require a join or where clause.

What you give is two table names, so far so good. It's totally unclear to me, what you mean with RecordN Codes. Of which table?

So far you would only need to do
Code:
Select * From SaleH ORDER By Account && <--- adapt the field name within the [SaleH] table, which denotes the account of the sale transaction
You might want to sum, you might want to order by transaction datetime, but that's not clear from your question and as you only give table names, we can't help you with details about that, not knowing fields of the tables.

Bye, Olaf.
 
Here requirement is merging of all transaction of all selected accounts selected by user to create 1 ledger of all selected accounts

so what technique will be applied to get all this merging
 
Hi mstrcmtr,

You need to link the two tables on a common field (e.g. cID) and write a SQL statement similar to this

Code:
SELECT * FROM Acnts, SaleH JOIN SaleH ON Acnts.cID = SaleH.cID ORDER BY Acnts.cID WHERE ... (you add more filter criteria) INTO ...

hth

MK
 
You'll sum() group by account:

Code:
SELECT account, SUM(amount) FROM SalesH GROUP BY account ORDER BY account

Again, not knowing your fields that's just the general idea. You might want to know the time span covered. Something along the lines of

Code:
SELECT account, SUM(amount), MIN(transactiondate) as startdate, MAX(transactiondate) as enddate FROM SalesH GROUP BY account ORDER BY account

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top