Board index » delphi » sum up with different conditions in SQL
Matthias Nolti
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Matthias Nolti
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
sum up with different conditions in SQL
My SQL problem cut down to an easy example :
A table with parts (numbers and names) and a table with amounts and an table parts: ID , PARTNO, PARTNAME ACTION=1 for sales, ACTION=2 for receipts How can I generate a list for a certain date that looks like this? BOOKNO , BOOKNAME , SALES, RECEIPTS, LOSSES, RETURNS How can I sum up the same column with all different conditions in a Thank you. |
Steve Koters
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:sum up with different conditions in SQLOn Tue, 04 Jan 2000 08:35:52 GMT, b...@mythos.in-berlin.de (Matthias QuoteNolting) wrote: table types (dBASE, Paradox, FoxPro) in the context of local SQL. (Follow-ups to the newsgroup only, please.) _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ |
Matthias Nolti
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:sum up with different conditions in SQLOn Tue, 04 Jan 2000 21:19:00 GMT, koter...@NOSPAMgte.net (Steve QuoteKoterski) wrote: I am using dbase tables with local BDE. Matthias |
Steve Koters
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:sum up with different conditions in SQLOn Wed, 05 Jan 2000 01:07:56 GMT, b...@mythos.in-berlin.de (Matthias QuoteNolting) wrote: Quote>Thank you steve, query. There is no inherent support in standard SQL (or local SQL) for this sort of query and so its requires multiple steps to accomplish. In local SQL, use two queries. The first retrieves data in an imperfect, intermediate form. This statement acts like an SQL view would, its result used as the source for a second statement. In the second statement, the data massaged in the first statement is refined to produce the final result set. In the first statement, use multiple SELECT statements concatenated into a /* Query for ACTION value of 1 (Sales) */ Then save this query to a text file (with a .SQL filename extension), In the second statement (executed from a TQuery or a saved query file) SELECT BOOKID, PARTNAME, SUM(SALES), SUM(RECEIPTS), _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ |
Matthias N?lti
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:sum up with different conditions in SQLOn Wed, 05 Jan 2000 16:27:34 GMT, koter...@NOSPAMgte.net (Steve QuoteKoterski) wrote: standard sql query. Thank you, I have tried half a day and it is a good way to learn SQL. Matthias |
1. PICK SYSTEM AND SQL AND UPS
2. Different SQL result with different language driver??
3. SQL - trapping not found condition?
4. SQL does not like OR conditions...
5. SQL does not like OR conditions...
6. How To Priority conditions in SQL
9. SQL-function SUM on a calculated field?
10. SQL - Sum & Rows