Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 988885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:42:08+00:00 2026-05-16T05:42:08+00:00

Today, I have started writing a query which is as given below: SELECT IP1.InstId,CAST(IP2.Quote

  • 0

Today, I have started writing a query which is as given below:


SELECT IP1.InstId,CAST(IP2.Quote AS DECIMAL(10,2)) AS 'CurrentPrice',IP1.Quote,(IP2.Quote-IP1.Quote) AS 'Change' 
FROM InstrumentPrices IP1
INNER JOIN InstrumentPrices IP2
ON IP1.InstId=IP2.InstId
INNER JOIN Instruments I
ON I.Id=IP2.InstId
INNER JOIN Games G
ON G.Id=IP1.GameId
AND G.CurrentPeriod-2=IP1.Period
AND G.CurrentPeriod-1=IP2.Period

Above query returned me with the expected results. Then I changed the output of IP2.Quote column in such a way that it should return the decimal points based on another column NDP in the Instruments table. The changed query is as given below:


SELECT IP1.InstId,CAST(IP2.Quote AS DECIMAL(10,I.NDP)) AS 'CurrentPrice',IP1.Quote,(IP2.Quote-IP1.Quote) AS 'Change' 
FROM InstrumentPrices IP1
INNER JOIN InstrumentPrices IP2
ON IP1.InstId=IP2.InstId
INNER JOIN Instruments I
ON I.Id=IP2.InstId
INNER JOIN Games G
ON G.Id=IP1.GameId
AND G.CurrentPeriod-2=IP1.Period
AND G.CurrentPeriod-1=IP2.Period

The second query returned a syntactical return which is as given below:


Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'I'.

I have no clue on the error returned by SQLServer.

Please help!!!

Thanks, Mahesh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:42:08+00:00Added an answer on May 16, 2026 at 5:42 am

    You seem to be trying to specify the scale of the decimal in the cast based on a value from a column, you just can’t do this it is not valid TSQL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have iPad which is on iOS 5. Today I have started getting error
I have recently started using ReSharper which is a fantastic tool. Today I came
greetings, today i have started to learn java using netbeans ide. i would like
I have just started playing with the ASP.Net MVC framework, and today I created
I just started C# today, and i have trouble reading an excel file. Here's
Today I started learning how to develop for Windows Phone, and I have a
I have been fighting this issue for some time so today I started a
Today I have started with setting up of Android Development Environment using Eclipse for
Today is my second day of trying to use amazon and i have started
The problem I have just started today, without really changing the code at all.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.