TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ismael Oliveira
1.6k
122
9.2k
Query not working
Jun 5 2021 2:27 PM
Hi.
I'm developing a forms system in C# and have to retrieve data from a SQLServer Database. There are 2 tables: Items and Inventory. In Items table there are products, which have a code of 1 and services, which have a code of 2. I must create a table that retrieves all products in Items table and relate them to the data in Inventory table. The problem is that maybe there are no data in this table. In this case I must bring a table with all items and fields concerning inventory empty. I tried the following query:
select I.ITEM_NA_CODIGO,
I.ITEM_TX_NOME, I.ITEM_TX_UNIDADE,
isnull(cast(IV.INVE_RE_QUANTIDADE as varchar(12)), '') as Quant,
isnull(cast(IV.INVE_RE_PRECOMEDIO as varchar(12)), '') as Preço
from ITEM I
full outer join INVENTARIO IV
on IV.ITEM_NA_CODIGO = I.ITEM_NA_CODIGO
and I.ITEM_NI_TIPOITEM = 1
and IV.INVE_DT_DATAINVENTARIO = '31/05/2021'
The result can be seen below:
The problem is that rows numbered from 5 to 8 are services and should not appear.
In the query, line "and I.ITEM_NI_TIPOITEM = 1" should guarantee this, but is not working.
Does anyone have any idea of my mistake?
Thanks.
Reply
Answers (
2
)
Login error whilst connecting to sqlsserver
How to update generated number field with number to every group from 1