SQL Table query

atuljadhavnetafim

Active Member
Joined
Apr 7, 2012
Messages
341
Office Version
  1. 365
Platform
  1. Windows
Dear Expert

i have one table "AR" in SQL Server, and in that table one column is there named "Arrear"
this column contain positive and negative numner like
123, 43, 54, 0, -34, -56, -678
now i want to bifurcate this number in category like
if the bumber >=0 then category will be "OD"
if the number <0 then category will be "FD"
i have one blank extra column in my data base, or we can create new column with above condition

but how

please help me
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You can use a CASE WHEN expression:

CASE (Transact-SQL)

Not tested, but for example:
Code:
SELECT Arrear, CASE WHEN Arrear >= 0 THEN 'OD' ELSE 'FD' END AS 'CATEGORY' FROM AR
 
Upvote 0
This allows you to assign the category on the fly, if you want to store the value in the database then I imagine that you would need to amend the process that writes the records to that table.
 
Upvote 0
This allows you to assign the category on the fly, if you want to store the value in the database then I imagine that you would need to amend the process that writes the records to that table.

i give u broad picture

i have 6 table in SQL Server, all table are linked with each other with different criteria
then i created one View which give me single table with all the selected category from all 6 tables, and that view table linked with my excel as pivot table

but i am not able to give formulas which i used to give in excel, i also can give above condition in excel but i want this shuould be happed in AR table itself, i have one etxra column with name "OD_FD" in AR table but it is NULL write now, i want result in same table in "OD_FD" column,

and if it is not possible then it should be done in my View table

i hope now i am clear
 
Upvote 0
You should be able to use the CASE construct in your view table to assign the category.
 
Last edited:
Upvote 0
You should be able to use the CASE construct in your view table to assign the category.


thanks for ur reply but i am not expert in SQL

will u please give me steps, will help me lot

after that i have another formula to incorporate this

and second thing, how much row will sql support ?
 
Upvote 0
What part are you not clear about? Can you post the SQL you used to create the view?
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,821
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top