I have a form in which there are three options for phone numbers ie cellphone, office phone and residence phone. The condition is the user is supposed to enter at least one number. My problem is i need to display the details of all the registered candidates in a gridview which has only one column named phone. i dnt knw how to write the query to check which phone number is entered by each candidate and display it. The priority between the phone numbers is given as office phone,cell phone then residence phone
You haven't stated what database you are using. However, if you are using SQL Server then you can use the COALESCE function. COALESCE returns the first non-null value in a series of values. It checks these values from l-r, so you can define an order of precedence. See the following example:
SELECT COALESCE([office], [cell], [residence]) AS Phone FROM MyTable
Hope this helps.
"No, his mind is not for rent
To any God or government" Tom Sawyer - Rush
@GUAccountID as nvarchar(30),
@GUInvID as nvarchar(30),
@InvoiceNo as numeric,
@InvoiceDate as datetime,
@DueDate as datetime,
@BatchNo as Decimal,
@GUStatmentID as nvarchar(30),
@StatmentNo as numeric,
@BatchSNCount as decimal,
@PAYMENTRECIVED as decimal(9,2),
@SubTotal as decimal(9,2),
@InvoiceAmount as decimal(9,2),
@VAT as decimal(9,2),
@OtherTax as decimal(9,2)
Declare @PrintDescription as nvarchar(100)
Declare @GUItemID as nvarchar(30)
Declare @PaymentAmt as decimal(9,2)
Declare @DueAmount as decimal(9,2)
Declare @CreditNoteAmount as decimal(9,2)
Declare @BFAmount as decimal(9,2)
I created a SQL Linked server for excel file. I am using that Linked server to Import the data from Excel files.When selecting the reords from this linked server , it returns the data in alphabetical order.
But I want the same order of columns which is in Excel file.
for selecting the records i am using tis Query:
select * from ExcelImport...Test$
where, ExcelImport is Linked server name and Test$ is the sheet in the excel file.