Beginner -Packages in sqlplus - package

I need to write a package to calculate totals per accounts and populate into table. My schema is XXCUS table name is Trial_Balance.
Tables: Account_description
Amount
Final amount
Please help
I am missing a few steps. Need to understand the concept.

Related

How to create a table with days column in react js?

I create one attendance management system right now. I stuck in someplace like I need to display all employee attendance report at a single table in that table I need to display name, days, and total hour of the month columns. I try some ways to achieve to create the day's column but I am failed to find a proper way to achieve this table so please help me how can I create this table.
i want the final output like this :-

MS SQL Server, arrays, looping, and inserting qualified data into a table

I've searched around for answer and I'm not sure how best to frame the question since I'm rather new to SQL Server.
Here's what I got going on: I get a weekly report detailing the products that have been sold and the quantity of each. This data needs to go into a yearly totals table. In this table the first column is the product_id and the next 52 columns are week numbers, 1-52.
There's a JOIN that runs on the product_id of both the weekly and yearly tables. That finds the proper row and column to put the weekly quantity data for that product.
Here's where I'm not sure what to do. In 2019 there are no product_id in that column. So there's nothing to JOIN on. Those product_id need to be added weekly if they aren't there. I need to take the weekly report of product_id and quantity and check each product_id to see if it's in the yearly table. If not I need to add it.
If I had it my way I'd create an array of the product_id numbers from the weekly data and loop through each one creating a new record in the yearly table for any product_id that is not already there. I don't know how best to do that in SSMS.
I've searched around and have found different strategies for this. Nothing strikes me as being a perfect solution. There's creating a #temp table variable, a UNION using exclude to get just those that aren't in the table, and a WHILE loop. Any suggestions would be helpful.
I ended up using a MERGE to solve this. I create a table WeeklyParts to dump the weekly data into. Then I do a MERGE with the yearly table inserting only those where the is no match. Works well.
-- Merge the PartNo's so that only unique ones are added to the yearly table
MERGE INTO dbo.WeeklySales2018
USING dbo.WeeklyParts
ON (dbo.WeeklySales2018.PartNo = dbo.WeeklyParts.PartNo)
WHEN NOT MATCHED THEN
INSERT (PartNo) VALUES (dbo.WeeklyParts.PartNo);

Pulling data only when it matches a column in another table

I'm new to the T-SQL language as my office is now using the Microsoft SQL Server Management Studio.
I am trying to pull all of the info from a large table but only when the item number shows in 1 column in another table. I have a small subset of items and I need to pull all the info from another that is more robust.
The small set table is named Itemmaster (IM) and has the following columns:
IM.item number
IM.description
IM.manuf
IM.item_Code
The second table, named Item_Directory (ID), has all of the info about the items including items with the same item codes. I want to pull all of the data from the Item_Directory where:
ID.item_Code = IM.Item_Code
No matter how I "think" it should be written, I seem to be wrong. I know this will probably be a simple formula but I'm still learning T-SQL.
My previous employer used Oracle and that just seemed easier for me to learn. Of course I am completely self taught so forgive me if I don't seem to know some of the basics.
Thanks for the suggestions.
select IM.item number,
IM.description,
IM.manuf,
IM.item_Code,
ID.*
From itemmaster IM
inner join item_details ID
on ID.item_Code = IM.Item_Code

Class diagram for online store

I need help on designing database table for online store. Here is my class diagram :
So I wonder is there anything wrong with my tables? Because it all seems separated. For example, this is how my online store works. First, needy resident creates product which link the Store needy resident table to Product table. Then, when customer order product, the information of needy resident would be pass along from product table to ordered product table. After that, I check for payment. If the ordered product status is paid, the ordered product price would be pass to Payment table and from the Payment table, I can update my Store needy resident's sales amount. It's very complicated and I am quite blur of it also.
So my question is, can somebody please help me check if my class diagram got some error for linking?
Thanks in advance.

Multiple tables access database

I am very new to Access and I am working on a database and I need help coming up with a solution:
I am recording data from a bunch of asphalt laying crews. Each crew has a record with a field for production and equipment. Each crew has varying types of equipment and varying quantities of equipment. Therefore, I would need to create a new table for the type and quantity of equipment every time I enter a new record... can someone please help me come up with a solution?
You do not need a new table for each record, you just need a properly set up table. Let us say:
Crews table
CrewID
Location
Etc
CrewMembers table
MemberID
Etc
CrewEquipment table
CrewID
EquipmentID
DateIn
DateOut
Etc
Equipment table
EquipmentID
Details
Etc
You might like to read http://r937.com/relational.html
With the above set-up, you can have a Crew form with subforms for members and equipment. You can get an idea from this create form to add records in multiple tables
Creating new table everytime is not solution, you should clear some RDBMS concept like normalization first. Create separate table for
crew member (which include crew member id, his name, salary/wages
List item per hour) equipments (which include equipments id, operation cost per hour etc)
Shift (can be separated by date and shift time etc)
Then create proper relationship between tables and this way you can create proper relational database system. so finish some basic tutorial first then start development.

Resources