vb.net - SQL query causing A TOP N value may not be negative error -


I am making an ASP.NET game rental website using SQL Server 2008 and I have a delivery page, when I Run this code as a TOP N value error.

I have found a query on my page that runs when the page loads with sqldatasource but there are no top minus shapes in it. SELECT TOP (SELECT MIN ([Rentability] [Balance balance] * (/ * Remaining at a time * / SELECT [subscriptions]] [game_ at_a_time] - (/ * Currently Number of games selected by the customer * [SELECT COUNT] * [FAR] [FAR] [FAR] [dispatch]. [Date_back] IS Null and [user]. [User_id] = [rent]. [User_id] ) Join [user] as the rest [subscription] ON [user]. [Subscription_ID] = [subscription] [membership_id] where [USES NET]. [User_ID] = 1 / * Choose your customer ID * / union [Change]. [MAX_ES] - (/ * Number of games totaled by the customer * / SELECT COUNT (* ) [Monthly (GateDate)) and [Ren Tals] from [RentedThisMonth] where month ([rent]. [Date]] = month (gate date () and year ([rent]. [Date]] and [ User]. [User_id] = [rent] [user_id]) [remaining] [remaining] user [user] on [membership] included [u] Yogkrta]. [Subscription_ID] = [subscriptions]. [Sdasyta_aidi] where [user]. [User_id] = 1 / * change it into your customer id * [game] [games] [games] [game] [game] [game] [games] [favorites] on [favorites] on [favorites] [Game_name] = [games]. [Name] [user] on [user] on [user_id] = [favorite]. [User_id] where [user] [User_id] = 1 / * change it to your customer id * / and [games]. [Volume] & gt; [Game-barcode] = [rentals]. [Game_barcode] and [rental]. [Date_back] is IS Nouvelle) Order by favorite (/ * currently copies of rent * / SELECT COUNT (*)] from [rental] where [game] [game_bar code] priority, favorites.

To make sure that you never receive a negative number, how to use the CASE statement: < / (Remaining)] [Balance] (Balance)) Balance balance (/ * Balance amount due) * / SELECT [Subscriptions] at a time. [Game_at_a_time] - [number of games selected by customer currently * / SELECT COUNT (*) as [from Rent]] [hire] where [rent]. [Date dated] IS Null [user] [User]. [User_id] = [rent]. [User_id]) [user] from [user] to join [user] [subscribers] on [subscribers] [Subscription_ID] = [Subscriptions]. [Subscription_ID] where [user] [User_ID] = 1 / * Change this to your customer id * / union [MAX_ES] - (/ * Number of games totaled by the customer * this month as rent / * SELECT COUNT (*) [Hire] Where [rent]. [Date]] = month (for user) [user] [user_id] = [rent]. [User_id]] join [user] from balance [subscribe] ] [the user]. [Subscription_ID] = [Subscriptions]. [Subscription_ID] where [user] [User_ID] = 1 / * Make this change in your customer ID * /) Rentability] [games] [games_barcode] from [games] [user] [user] [user] [User_id] = [games]. [Name] = [games]. [Name] [user] on [user] on [user_id] = [favorite]. / * Change it to your customer id * / and [games]. [Volume] & gt; [Game-barcode] = [rentals]. [Game_barcode] and [rental]. [Date_back] is IS Nouvelle) Order by favorite (/ * currently copies of rent * / SELECT COUNT (*)] from [rental] where [game] [game_bar code] priority, favorites.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -