Home » RDBMS Server » Server Administration » Is it possible
Is it possible [message #374747] Thu, 28 June 2001 05:47 Go to next message
Danny
Messages: 11
Registered: June 2001
Junior Member
If I have two tables, the first one is master, has three records, A, B, C, the second one is for everyday transaction, like
day 1, A 300, B 200, (no C)
day 2, B 300. (no A, C)
Can I use a sql statement to generate the result like
day 1 : A 300, B 200, C 0
day 2 : A 0, B 300, C 0
The headache part is how to add a "0" as a complement to the items which didn't shown on table two of that day. Thanks!
Re: Is it possible [message #374749 is a reply to message #374747] Thu, 28 June 2001 06:10 Go to previous messageGo to next message
Rob Zirpolo
Messages: 2
Registered: June 2001
Junior Member
You need to use the NVL function. so your script should be typed

SELECT NVL(A, 0), NVL(B, 0), NVL(C, 0)
FROM <MASTER TABLE>

What NVL does is that if NULL is present it will place whatver value entered after the comma - in this case 0.

This should work easy - let me know if any probs.
Re: Is it possible [message #374758 is a reply to message #374747] Thu, 28 June 2001 20:57 Go to previous message
Danny
Messages: 11
Registered: June 2001
Junior Member
Thanks for your reply, the problem is, if I add one Item to Table 1, like "D", I need to modify my sql script to reflect it.

Moreover, this script seems not work out in VB, does it?

Best Regards

Danny
Previous Topic: loading excel data into oracle database
Next Topic: help
Goto Forum:
  


Current Time: Sat Jul 06 08:09:59 CDT 2024