Hi...
I'm the new comer in this scripts network. Also quite new in SQL coding.
I would like to ask some sql scripts.
Eg. I have a table as belows :
Item Warehouse
---------------------------------
BTN001 070
BTN001 073
BTN002 070
BTN003 073
BTN004 070
BTN004 073
Then the result I want is only for item BTN002.
That means I only want to sort out item which is existed in 070, but not exist in 073.
But not the other way. I don't need item which is existed in 073, but not exist in 070.
So, how is the sql scripts for above ? Kindly help.
Thanks a lot.
6 1375
Hi...
I'm the new comer in this scripts network. Also quite new in SQL coding.
I would like to ask some sql scripts.
Eg. I have a table as belows :
Item Warehouse
---------------------------------
BTN001 070
BTN001 073
BTN002 070
BTN003 073
BTN004 070
BTN004 073
Then the result I want is only for item BTN002.
That means I only want to sort out item which is existed in 070, but not exist in 073.
But not the other way. I don't need item which is existed in 073, but not exist in 070.
So, how is the sql scripts for above ? Kindly help.
Thanks a lot.
Hi and welcome to TSDN.
Try - select * from tableName where Warehouse = 070 and Item not in (select Item from tableName where Warehouse <> 070)
Hi and welcome to TSDN.
Try - select * from tableName where Warehouse = 070 and Item not in (select Item from tableName where Warehouse <> 070)
Hi...
Thanks a lot for the quick reply. I just try it with my winSQL, but it just didn't work.
THere's no data sort out. Could you please advise furthermore ?
Thanks a lot.
Hi...
Thanks a lot for the quick reply. I just try it with my winSQL, but it just didn't work.
THere's no data sort out. Could you please advise furthermore ?
Thanks a lot.
Hi...
I try to change some of the code and found below code work : - SELECT * FROM tableName WHERE Warehouse = 070 AND Item NOT IN (SELECT Item FROM tableName WHERE Warehouse = 073)
-
So, it should be ok now.. THanks a lot for the guidelines.... ^_^
Hi...
I try to change some of the code and found below code work : - SELECT * FROM tableName WHERE Warehouse = 070 AND Item NOT IN (SELECT Item FROM tableName WHERE Warehouse = 073)
-
So, it should be ok now.. THanks a lot for the guidelines.... ^_^
What if you have a third warehouse, say 074 and want the items only in 070 ?
I think you should try to get the statement with not equal to 070 to work. What error did you get when you tried it?
Hi...
I'm the new comer in this scripts network. Also quite new in SQL coding.
I would like to ask some sql scripts.
Eg. I have a table as belows :
Item Warehouse
---------------------------------
BTN001 070
BTN001 073
BTN002 070
BTN003 073
BTN004 070
BTN004 073
Then the result I want is only for item BTN002.
That means I only want to sort out item which is existed in 070, but not exist in 073.
But not the other way. I don't need item which is existed in 073, but not exist in 070.
So, how is the sql scripts for above ? Kindly help.
Thanks a lot.
-
SELECT e.* FROM <table_name> e WHERE e.warehouse = '070' AND 1 = (SELECT COUNT(warehouse) FROM <table_name> WHERE item = e.item)
-
What if you have a third warehouse, say 074 and want the items only in 070 ?
I think you should try to get the statement with not equal to 070 to work. What error did you get when you tried it?
Hi...
Actually the original data has more than 1 warehouse.. And by using the modification sql, it works also. So it's ok already now.
BY using the 1st sql, I didn't get any error msg, only there's no data sort out.
But using the 2nd sql that I've modified from yours, success...
So, thanks a lot..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: web developer |
last post by:
hi
i got a query that takes about 14 mins
here it is
select BDProduct.ProductCode,BDProduct.ProductName,SALTerritory.TerritoryID...
|
by: Raymond Lewallen |
last post by:
I have a dataview in which the sort property will not sort the dataview.
Here's is a simple scenario similar to what I am doing:
Class Foo
Private Function Retrieve() As DataView
' Returns a...
|
by: none |
last post by:
I run a web site that searches for data on other web sites and displays
the results for the user onscreen.
Currently, it uses perl to fetch the data, sort it and display it. It
can take quite a...
|
by: Gunjan Garg |
last post by:
Hello All,
I am working to create a generic datagrid which accepts a
datasource(ListData - This is our own datatype) and depending on the calling
program customizes itself for sorting,...
|
by: Rainmaker |
last post by:
Hi,
Can anyone tell me an efficient algorithm to sort an array of strings?
Keep in mind that this array is HUGE and so the algorithm should me
efficient enough to deal with it.
Thanks
|
by: Lyners |
last post by:
I am trying to figure out the best way to do this (currently I am having a
problem sorting). I have a vb.net program that contains 2 datagrids on a form
for the end user. When the user is ready to...
|
by: Les Juby |
last post by:
I need to extract records from a database subject to conditions and
only thereafter give the users the choice of which fields to sort the
results on.
In this situation I can't write back to a...
|
by: weetat.yeo |
last post by:
Hi all ,
I have sql statement below ,
SELECT
serial_no,host_name,chasis_model,chasis_flash_size,chasis_dram_size,...
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
|
by: neocortex |
last post by:
Hello!
I am a newbie in Python. Recently, I get stuck with the problem of
sorting by two criteria. In brief, I have a two-dimensional list (for
a table or a matrix). Now, I need to sort by two...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |