Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Display Supplier (Help) Expand / Collapse
Author
Message
Posted Sunday, September 2, 2012 4:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 3, 2012 9:34 PM
Points: 5, Visits: 5
I need to display the Name of all US-based, Japan-based and German-based suppliers. Order the results by Name in ascending order. Can you help me?
Post #1353196
Posted Sunday, September 2, 2012 5:43 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:50 AM
Points: 1,900, Visits: 18,984
richesflow (9/2/2012)
I need to display the Name of all US-based, Japan-based and German-based suppliers. Order the results by Name in ascending order. Can you help me?


Hello and welcome to the site.
for future reference you will find that for the majority of questions it is helpful to us and you if you can provide some example background details...this is often referred to as DDL / insert scripts......if you arent sure how to do this please post back.


below is some sample code that you can paste into SSMS and run.


USE [tempdb]
GO

-- create a table and insert some data to demonstrate what I am talking about
-- this will allow potential helpers to easily provide thoughts and solutions

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Suppliers]') AND type in (N'U'))
DROP TABLE [dbo].[Suppliers]
GO


CREATE TABLE [dbo].[Suppliers](
[Supplier_ID] [int] IDENTITY(1,1) NOT NULL,
[Supplier_name] [varchar](50) NULL,
[Supplier_country] [varchar](50) NULL,
CONSTRAINT [PK_SUPPLIERS] PRIMARY KEY CLUSTERED
(
[Supplier_ID] ASC
)) ON [PRIMARY]

GO

SET IDENTITY_INSERT [dbo].[Suppliers] ON;

INSERT INTO [dbo].[Suppliers]([Supplier_ID], [Supplier_name], [Supplier_country])
SELECT 1, N'Acme Trade', N'Japan' UNION ALL
SELECT 2, N'Xyzzy Co', N'Germany' UNION ALL
SELECT 3, N'Zeus and Company', N'UK' UNION ALL
SELECT 4, N'Lincoln Inc', N'USA' UNION ALL
SELECT 5, N'Whamo Widgets', N'USA' UNION ALL
SELECT 6, N'MoCarCo', N'Germany'

SET IDENTITY_INSERT [dbo].[Suppliers] OFF;

-- here is some code that might provide some ideas.

SELECT Supplier_name, Supplier_country
FROM SUPPLIERS
WHERE (Supplier_country IN ('Germany', 'USA'))
ORDER BY Supplier_country, Supplier_name



__________________________________________________________________
you can lead a user to data....but you cannot make them think !
__________________________________________________________________
Post #1353209
Posted Sunday, September 2, 2012 7:33 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:03 AM
Points: 36,975, Visits: 31,492
richesflow (9/2/2012)
I need to display the Name of all US-based, Japan-based and German-based suppliers. Order the results by Name in ascending order. Can you help me?


Based on this and the other questions you've asked, I'd recommend taking a starter course on SQL. You can find such a thing at W3Schools.com.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1353217
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse