sql query syntax?
i write this query but error get : column not found
how can i write ?
SELECT c.stock_cat_name, a.stock_code, c.description, a.date,
IIF(MID(a.type,2,1)="I",SUM(a.quantity),0) AS iqty,
IIF(MID(a.type,2,1)="O",SUM(a.quantity),0) AS oqty
FROM stock_tran AS a LEFT JOIN stock AS c ON c.stock_code=a.stock_code
WHERE a.date>=[from_date] And a.date<=[to_date]
GROUP BY c.stock_cat_name, a.stock_code, c.description, a.date,
MID(a.type,2,1)
ORDER BY c.stock_cat_name, a.stock_code, a.date, MID(a.type,2,1);
this database driver sage line 50 odbc
i write a simpale query of this database, successful run but when i
write in condition (IF) is not run error comes : column not found.
rashesh 2 8465
Perhaps I'm missing something here, but T-SQL doesnt support IIF function.
You should use CASE. Something like:
SELECT c.stock_cat_name, a.stock_code, c.description, a.date,
CASE WHEN MID(a.type,2,1)="I" THEN SUM(a.quantity) ELSE 0 END AS iqty,
CASE WHEN MID(a.type,2,1)="O" THEN SUM(a.quantity) ELSE 0 END AS oqty
FROM stock_tran AS a LEFT JOIN stock AS c ON c.stock_code=a.stock_code
WHERE a.date>=[from_date] And a.date<=[to_date]
GROUP BY c.stock_cat_name, a.stock_code, c.description, a.date,
MID(a.type,2,1)
ORDER BY c.stock_cat_name, a.stock_code, a.date, MID(a.type,2,1);
MC
"Rshah" <rs********@gmail.comwrote in message
news:11*********************@v45g2000cwv.googlegro ups.com...
sql query syntax?
i write this query but error get : column not found
how can i write ?
SELECT c.stock_cat_name, a.stock_code, c.description, a.date,
IIF(MID(a.type,2,1)="I",SUM(a.quantity),0) AS iqty,
IIF(MID(a.type,2,1)="O",SUM(a.quantity),0) AS oqty
FROM stock_tran AS a LEFT JOIN stock AS c ON c.stock_code=a.stock_code
WHERE a.date>=[from_date] And a.date<=[to_date]
GROUP BY c.stock_cat_name, a.stock_code, c.description, a.date,
MID(a.type,2,1)
ORDER BY c.stock_cat_name, a.stock_code, a.date, MID(a.type,2,1);
this database driver sage line 50 odbc
i write a simpale query of this database, successful run but when i
write in condition (IF) is not run error comes : column not found.
rashesh
MC wrote:
Perhaps I'm missing something here, but T-SQL doesnt support IIF function.
You should use CASE. Something like:
SELECT c.stock_cat_name, a.stock_code, c.description, a.date,
CASE WHEN MID(a.type,2,1)="I" THEN SUM(a.quantity) ELSE 0 END AS iqty,
CASE WHEN MID(a.type,2,1)="O" THEN SUM(a.quantity) ELSE 0 END AS oqty
FROM stock_tran AS a LEFT JOIN stock AS c ON c.stock_code=a.stock_code
WHERE a.date>=[from_date] And a.date<=[to_date]
You can write this as
WHERE a.date BETWEEN [from_date] AND [to_date]
GROUP BY c.stock_cat_name, a.stock_code, c.description, a.date,
MID(a.type,2,1)
ORDER BY c.stock_cat_name, a.stock_code, a.date, MID(a.type,2,1);
Did you mean to omit c.description from the ORDER BY? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: joemyre |
last post by:
Hi everyone,
What I'm trying to do is take php variables i got from user input, and
pass them as the MySQL query terms.
$query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
|
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: Paradigm |
last post by:
I want to create a pass through query in Access to get data from a MYSQL
table. I need to do this using code so that sertain aspects of the query can
be changed.
When I look at the SQL version of...
|
by: deko |
last post by:
I'm trying to update the address record of an existing record in my mdb with
values from another existing record in the same table. In pseudo code it
might look like this:
UPDATE tblAddress SET...
|
by: KevLow |
last post by:
Hi,
Hope some kind soul can help me out here..
I'm trying to programmatically modify the column headings of a crosstab
query such that it can be dynamic based on user specified period (Month...
|
by: Patrick A |
last post by:
All -
I have the following in the Field row of a column in a query that runs
fine against a local table:
MSA: InStr(!!,!)
I'm now trying to run the query against a linked DB2 table. I get...
|
by: Crash |
last post by:
Hi,
..NET v1.x SP1
VS 2003
SQL Server 2000 SP3
Server 2000, XP, Server 2003
I would like to programmatically execute {possibly many} SQL Server
batch scripts. Aka I have many scripts that...
|
by: windandwaves |
last post by:
Hi Folk
I have a query:
SELECT COUNT( `SIS`.`ID` ) c, D
FROM `SIS` , `SID`
WHERE `SID_ID` = `SID`.`ID`
AND `BRO` <> "bot"
GROUP BY SID.ID
|
by: Daniel |
last post by:
In Microsoft Access I can write a query that includes the criteria:
Between Date()-7 And Date()
to retrieve the records from a table that fall within the last week.
I'm trying to write a...
|
by: bryant |
last post by:
Hi all.
I am new to ASP and working in Expression Web. The following query
displays the information I need in the gridview for a single record.
SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |