CREATE PROCEDURE dbo.p_dir_info @user varchar(20),@parent_path varchar(255) ASSELECT *FROM (SELECT d.[user],d.path ,d.parent_path,d.dir,d.create_time,ISNULL(SUM(f.[count]),0) AS [count],ISNULL(SUM(f.[size]),0) AS [size]FROM dbo.t_directories d LEFT O

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/21 11:55:46
CREATEPROCEDUREdbo.p_dir_info@uservarchar(20),@parent_pathvarchar(255)ASSELECT*FROM(SELECTd.[user],d

CREATE PROCEDURE dbo.p_dir_info @user varchar(20),@parent_path varchar(255) ASSELECT *FROM (SELECT d.[user],d.path ,d.parent_path,d.dir,d.create_time,ISNULL(SUM(f.[count]),0) AS [count],ISNULL(SUM(f.[size]),0) AS [size]FROM dbo.t_directories d LEFT O
CREATE PROCEDURE dbo.p_dir_info @user varchar(20),@parent_path varchar(255) AS
SELECT *
FROM (SELECT d.[user],d.path ,d.parent_path,d.dir,d.create_time,
ISNULL(SUM(f.[count]),0) AS [count],ISNULL(SUM(f.[size]),0) AS [size]
FROM dbo.t_directories d LEFT OUTER JOIN
(SELECT path,COUNT([file]) AS [count],SUM([size]) AS [size]
FROM t_files
GROUP BY path) f ON d .path = f.path
WHERE d.[user] = @user and d.parent_path=@parent_path GROUP BY d.path ) dir ORDER BY create_time
其中table为
CREATE TABLE [dbo].[t_directories] (
[id] [int] IDENTITY (1,1) NOT NULL ,
[user] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[path] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[parent_path] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[dir] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[create_time] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[t_files] (
[id] [int] IDENTITY (1,1) NOT NULL ,
[user] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[file] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[path] [varchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[size] [bigint] NOT NULL ,
[upload_time] [datetime] NOT NULL
) ON [PRIMARY]

CREATE PROCEDURE dbo.p_dir_info @user varchar(20),@parent_path varchar(255) ASSELECT *FROM (SELECT d.[user],d.path ,d.parent_path,d.dir,d.create_time,ISNULL(SUM(f.[count]),0) AS [count],ISNULL(SUM(f.[size]),0) AS [size]FROM dbo.t_directories d LEFT O
d.[user], d.path , d.parent_path, d.dir, d.create_time,这几个没有出现在group by中,是没有办法取得到的,要想得到就要在group by中加上他们,或者用聚合
你如果原意是只想根据path分组而又想得到上面几个字段的换还是加个游标吧

CREATE PROCEDURE dbo.p_dir_info @user varchar(20),@parent_path varchar(255) ASSELECT *FROM (SELECT d.[user],d.path ,d.parent_path,d.dir,d.create_time,ISNULL(SUM(f.[count]),0) AS [count],ISNULL(SUM(f.[size]),0) AS [size]FROM dbo.t_directories d LEFT O SQL 请高手帮忙看一下以下语法哪里有错误.USE tempdb;IF OBJECT_ID('dbo.Arrays') IS NOT NULL DROP TABLE dbo.Arrays;CREATE TABLE dbo.Arrays(arrid VARCHAR(10) NOT NULL PRIMARY KEY,array VARCHAR(8000) NOT NULL)GOINSERT INTO Arrays(arrid,arr CREATE OR REPLACE PROCEDURE XXX as RT.CREATE OR REPLACE PROCEDURE XXX as 大致意思我只知道是存储过程的定义,但具体就不清楚了.还有那个XXX一般代表什么?这句话是必须的么? create create create create create create ORACLE 表名为变量create PROCEDURE up_CreateTable(tableName_in IN VARCHAR2)ASDeclare SQL_in VARCHAR2(5000);BEGINSQL_in := 'CREATE TABLE '||tableName_in||' (DM VARCHAR2(20) NOT NULL,MC VARCHAR2(60) NOT NULL,BZSM VARCHAR2(100))tablespace USERS pctf bench procedure procedure是什么意思? lnvalid procedure procedure是什么 为过程或函数 procedure_goods_insert 指定了过多的参数.create procedure procedure_goods_insert(@goods_id int,@goods_name varchar(20),@goods_guig varchar(50),@goods_unit varchar(6),@goods_txt text)asinsert into goods values(@goods_id,@good 请问Oracle中如何在通过创建一个package,然后在package中创建procedure的语法是怎么样的啊是不是没有create procedure这样的语法啊,我今天看好像还在package中有存储过程的声明,还有存储过程的实现, 请教一个SQL汇总语句:把下表中按AA和BB汇总后的BB的个数(每个BB汇总1次),CC同理.use [MYTEST] CREATE TABLE [dbo].[Table_TEST]( [ID] [int] IDENTITY(1,1) NOT NULL,[AA] [nchar](10) NULL,[BB] [nchar](10) NULL,[CC] [nchar](10) 数据库sql语句,建立表的时候.加不加不加[]中括号什么区别?比如:create table [dbo].[T]([id] [int] primary key,[name] [varchar] not null)书上是这么写的带中括号的.但是也我把中括号去了可是可以通过的(