Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Yesterday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Yesterday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Wednesday at 5:34 PM
Pure VPN - Up to 27 Months
vgp
Updated:
Jun 5, 2026
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Jun 2, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
SQL Waddo
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="rosharavinda" data-source="post: 16716257" data-attributes="member: 68151"><p>Please SQL waddo mata mekata help ekak denna.</p><p></p><p>We have given a set of records in a table. You need to write an SQL function without using CURSORs to return cost per a given number of credits. Credit cost information is given in a table called “tblLoyaltyDiscount” and “tblLoyaltyDiscount” is given below. If you are interested in creating the table in your own database and try, scripts are given at the bottom of this document. You can give an approximate logic in TSQL.</p><p></p><p>[ATTACH]51655[/ATTACH]</p><p></p><p>Cost is calculated by multiplying DiscCostPerCredit with number of credits. DiscCostPerCredit is taken from the closest minimum credit record. Some examples are given below.</p><p></p><p>1 credit = £195.00</p><p>3 credits = £500.00 (can be taken directly from the table)</p><p>4 credits = £668.00 (167.00 * 4, 167.00 taken from the record for 3 credits)</p><p>5 credits = £800.00 (can be taken directly from the table)</p><p>6 credits = £960.00 (160.00 * 6, 160.00 taken from the record for 5 credits)</p><p>12 credits = £1800.00 (150.00 * 12, 150.00 taken from the record for 10 credits)</p><p>720 credits = £72000.00 (100.00 * 720, 100.00 taken from the record for 500 credits)</p><p></p><p></p><p></p><p></p><p>Script to create tblLoyaltyDiscount</p><p></p><p>SET ANSI_NULLS ON</p><p>GO</p><p></p><p>SET QUOTED_IDENTIFIER ON</p><p>GO</p><p></p><p>CREATE TABLE [dbo].[tblLoyaltyDiscount](</p><p> [LoyaltyDiscountID] [int] IDENTITY(1,1) NOT NULL,</p><p> [Sequence] [int] NULL,</p><p> [CreditCount] [int] NULL,</p><p> [DiscountedTotal] [decimal](18, 2) NULL,</p><p> [DiscCostPerCredit] [decimal](18, 2) NULL,</p><p> [Active] [bit] NULL</p><p>) ON [PRIMARY]</p><p></p><p>GO</p><p></p><p></p><p></p><p>Scripts to insert data into tblLoyaltyDiscount</p><p></p><p></p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p> VALUES (1,1,195,195,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (2,3,500,167,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (3,5,800,160,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (4,10,1500,150,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (5,25,3500,140,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (6,50,6500,130,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (7,100,12000,120,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (8,250,27500,110,'True')</p><p>insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active)</p><p>VALUES (9,500,50000,100,'True')</p><p></p><p>Please help me Guys.<img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /><img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /><img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /><img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /></p></blockquote><p></p>
[QUOTE="rosharavinda, post: 16716257, member: 68151"] Please SQL waddo mata mekata help ekak denna. We have given a set of records in a table. You need to write an SQL function without using CURSORs to return cost per a given number of credits. Credit cost information is given in a table called “tblLoyaltyDiscount” and “tblLoyaltyDiscount” is given below. If you are interested in creating the table in your own database and try, scripts are given at the bottom of this document. You can give an approximate logic in TSQL. [ATTACH]51655._xfImport[/ATTACH] Cost is calculated by multiplying DiscCostPerCredit with number of credits. DiscCostPerCredit is taken from the closest minimum credit record. Some examples are given below. 1 credit = £195.00 3 credits = £500.00 (can be taken directly from the table) 4 credits = £668.00 (167.00 * 4, 167.00 taken from the record for 3 credits) 5 credits = £800.00 (can be taken directly from the table) 6 credits = £960.00 (160.00 * 6, 160.00 taken from the record for 5 credits) 12 credits = £1800.00 (150.00 * 12, 150.00 taken from the record for 10 credits) 720 credits = £72000.00 (100.00 * 720, 100.00 taken from the record for 500 credits) Script to create tblLoyaltyDiscount SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblLoyaltyDiscount]( [LoyaltyDiscountID] [int] IDENTITY(1,1) NOT NULL, [Sequence] [int] NULL, [CreditCount] [int] NULL, [DiscountedTotal] [decimal](18, 2) NULL, [DiscCostPerCredit] [decimal](18, 2) NULL, [Active] [bit] NULL ) ON [PRIMARY] GO Scripts to insert data into tblLoyaltyDiscount insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (1,1,195,195,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (2,3,500,167,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (3,5,800,160,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (4,10,1500,150,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (5,25,3500,140,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (6,50,6500,130,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (7,100,12000,120,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (8,250,27500,110,'True') insert INTO [dbo].[tblLoyaltyDiscount] (Sequence,CreditCount,DiscountedTotal,DiscCostPerCredit,Active) VALUES (9,500,50000,100,'True') Please help me Guys.:(:(:(:( [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom