473,800 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query : Total not displaying

41 New Member
Hi,

I hve some problem in query. My query is too long and linked with many table which make you confusion. So, hereby i explain you my problem by below example.

The tables and Fields are..

student tbl
---------
stud_id
stud_name
stud_city
Stud_fees

stud_ded_tble
---------
stud_id
Ded_Remarks
Ded_Amt
(This table is designed as a student may hve different type of discount.)


payment_tbl
---------
stud_id
Paid_amt

Now. I need one query which shall fullfill all below requirement.

-Assume that all the students has to pay the amount.
-Total(Payable_A mt)
-Calculation : (Stud_fees-Ded_amt-Paid_Amt)
-The Condition : Even if the student not having Ded_Amt or Paid_Amt, it shd list out Stud_Fees as the Total(Payable_A mt) as he has neither Ded_Amt nor Paid_Amt.

My problem is that, i m getting Total(Payble_Am t) ONLY those who hve paid_Amt. Rest Total(Payble_Am t) is not coming.

Can u pls show me the query so that i can try my query according to your query.

Thanks in advance.

ngr.
Apr 23 '07 #1
5 2497
MMcCarthy
14,534 Recognized Expert Moderator MVP
Your first problem is that you have the same primary key on each table. Each table should have it's own primary key and stud_id should only be a foreign key on any table other than the Student table.

Check out this tutorial

Normalisation and Table structures
Apr 24 '07 #2
solargovind
41 New Member
Your first problem is that you have the same primary key on each table. Each table should have it's own primary key and stud_id should only be a foreign key on any table other than the Student table.

Check out this tutorial

Normalisation and Table structures
=====

The Stud_id is foreign key only. And, in all the tables the primary key has been already set which i forgot to mention in the above..

Pls.suggest me for my further process.

Thnx...

ngr..
Apr 24 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT ([student tbl].Stud_fees - nz([stud_ded_tble].Ded_amt,0) - nz([payment_tbl].Paid_Amt,0) As PayableAmount
  2. FROM (([student tbl] LEFT JOIN [stud_ded_tble]
  3. ON [student tbl].stud_id = [stud_ded_tble].stud_id)
  4. LEFT JOIN  [payment_tbl]
  5. ON  [student tbl].stud_id = [payment_tbl].stud_id)
  6.  
Apr 24 '07 #4
solargovind
41 New Member
Its great.

I just needed to use 'Nz' function for Null values.

Its working fine.

Thanks a lot.

ngr.
Apr 24 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Its great.

I just needed to use 'Nz' function for Null values.

Its working fine.

Thanks a lot.

ngr.
You're welcome.
Apr 24 '07 #6

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

Similar topics

3
7811
by: krystoffff | last post by:
Hi I would like to paginate the results of a query on several pages. So I use a query with a limit X offset Y to display X results on a page, ok. But for the first page, I need to run the same query with a count(*) to know how many pages I will get (number total of rows/ X). The problem is my query is very slow (maybe 5s) because there is much
5
2396
by: Alicia | last post by:
Yes, but will that skip a week and group by the date for me? I basically wanted something that would do a count of the dates, then group them by their week name.. BEFORE: Resource Date Total number of times that date Appeared (Count) 4/3/03 4 4/4/03 2 (note 4/4/03 showed up twice)
4
5713
by: Stephen Young | last post by:
Hello Have a bit of a problem, im trying to get the total number of hours:minutes for all actions over the month in a query, have tried two methods to no luck... Duration This Month: Format(Sum(.-.),"hh:nn") displays the total hours but rolls over anything over 1 day and starts
5
1770
by: Otie | last post by:
I have a select query that groups records together, specifically baseball players and their home runs and at-bats. I want to create a query that displays , , and and that sorts ASCENDING on the field. My field is: AB_per_HR: / If I set the SORT to Ascending, I get an error message saying I tried
0
1279
by: badboybrown | last post by:
I'm sorry to ask this, but I just can't figure it out and it's probably because it's not possible. I have a Cross-tab query that shows me the sum of items received by brand(Columns) for every month(Rows). It also has a sum at the end of each row to give me a total for the month. I would like to _show_ this on a Form, with a "Year Total" calculated from the month totals.
1
1741
by: deshg | last post by:
Hey everyone, I have a query displaying total customers within specific sectors using the groupby and sum arguments. The only issue being it doesn't display sectors with 0 customers at all (i would like it to list them with 0 total). I just wondered if there was a way of doing this or whether it will only ever show results with positive counts? Thanks so much, Dave
4
3137
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the first query where Item is Null. I use a subreport for the details, and the results display correctly. However, the Report_Details event of the subreport is executed about 2 or 3 times more than I would expect (I think 3 times when I have a
2
1506
by: beepstreet | last post by:
I have a question of calculating the total cost of breakfast, dinner and lunch and also displaying the total amount sold in a week. The cost for... breakfast is 2.45 lunch is 3.75 dinner is 3.95 This is the code i have so far Dim breakfast As Double Dim lunch As Double
6
3128
by: keyur1719 | last post by:
Hi, I have a crosstab query which is based on a simple select query. Here is how the query works.. The base query gets it date from employee table and their incentives table for the given quarter. This query feeds to the Crosstab query for displaying the quarterly data. I have a field in the crosstab query which calculates the sum of all three months in the quarter. I want to give ranks to this quarterly total in the crosstab query. I...
0
9551
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
10507
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
10279
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
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
5473
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
4150
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
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
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.